Re: Help Saving .Tif File after Mask


Simon Tarr
 
Edited

Hi Luke, thanks for the reply. Your code has helped me move past my previous error.
I had to delete the indexes argument when calling `write' but apart from that, it works like a charm.

Thank you for your help!


On Wed, Apr 7, 2021 at 02:41 AM, Luke wrote:
with rasterio.open('/data/my_output.tif', 'w', 
               driver='GTiff',
               height=masked_raster.shape[1], 
               width=masked_raster.shape[2], 
               count=1, 
               dtype=rasterio.ubyte, 
               crs=file.crs, 
               transform=transform
              ) as outfile:
            outfile.write(masked_raster, indexes=1) 

Join main@rasterio.groups.io to automatically receive all group messages.