pysheds
pysheds copied to clipboard
example usage of to_raster?
Hello,
I'd like to export the pysheds-created catchment grid to a raster file. I see that you do have a grid.to_raster()
function already, but I'm having trouble using it.
Here's the notebook I'm working with (4th cell from the top): https://github.com/cfandel/gottesacker/blob/master/subwatersheds.ipynb
When I run this:
grid.to_raster('catch','catch.tiff',blockxsize=50,blockysize=50)
I get the following error:
CPLE_AppDefinedError: MissingRequired:TIFF directory is missing required "StripOffsets" field
Would you be able to provide an example of correct usage of the to_raster()
function, or have any tips on what's causing the error?
Thanks!
-Chloé
Hi,
This seems to be an issue with rasterio or GDAL, but I don't know the reason. Do you need the blocksize arguments? If not, you may want to try
grid.to_raster(data_name="catch", file_name="catch.tiff")
or, with compression turned on,
grid.to_raster(data_name="catch", file_name="catch.tiff", profile={"compress":"LZW","driver":"GTiff","count":1})
.
Good luck! Andreas