rvalavi / blockCV

The blockCV package creates spatially or environmentally separated training and testing folds for cross-validation to provide a robust error estimation in spatially structured environments. See
https://doi.org/10.1111/2041-210X.13107
GNU General Public License v3.0
109 stars 24 forks source link

Exporting Blocks and its fold names as Shapefile #46

Closed ozgurhsyndgn closed 9 months ago

ozgurhsyndgn commented 9 months ago

All my respect and appreciation for the package you've created,

I'm using the package in my thesis and want to have better visuals with a GIS layout. I'm trying to export the blocks and it's id/fold name/numbers in it as a shapefile.

How can I export a cv_spatial object as a shapefile?

I'm lacking with data manipulation a bit, thanks for your help in advance,

Best regards,

Huseyin

rvalavi commented 9 months ago

Hi @ozgurhsyndgn

Thanks for your interest in blockCV.

You can use your_cv_obj$blocks to access the blocks. Then use the sf package to write it to a file e.g.:

sf::st_write(your_cv_obj$blocks, "file_path.shp")
ozgurhsyndgn commented 9 months ago

Thank you Mr. Valavi, this is what I was looking for!

Kind Regards.