Re: Creating rasterio dataset without IO


Brendan Ward
 

Nic,

if your goal is to mask the data, you can replicate some of the processing steps in the `mask` chain:
https://github.com/mapbox/rasterio/blob/master/rasterio/mask.py

Specifically, you'd need to figure out the transform and output shape for your mask based on your source data and polygon, then it is just a matter of calling geometry_mask with those parameters:
https://github.com/mapbox/rasterio/blob/1.1.3/rasterio/mask.py#L108-L109

Then apply that mask to your data, which you've already prepared in a prior step.

Having the dataset as a rasterio.io.Dataset gives us access to many of the properties we need to be able to calculate those parameters.  To create a mask we don't actually need to read data from the dataset, it's only when the mask is applied that we need those data.  This use case seems outside the intent for MemoryFile.

I hope that helps.

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