mdbartos / pysheds

:earth_americas: Simple and fast watershed delineation in python.
GNU General Public License v3.0
707 stars 191 forks source link

example usage of to_raster? #91

Open cfandel opened 5 years ago

cfandel commented 5 years ago

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é

itati01 commented 5 years ago

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