Re: Serializing and deserializing rasterio object


Juliano <juliano.ecc@...>
 

Yes Sean, I mean the object returned by rasterio.open().

I'm doing a remote function that crops a small polygon from a large image, and returns only that cropped region.
The function is not able to persist the outcome on disk, so I have to return it as a JSON.

I was wondering if could save some time by not serializing and deserializing by myself.
The numpy matrix (from .read()) I can do it easily, but the metadata uses some classes in its properties (crs and transform) and json.dumps() complains about that and doesn't let me generate a dictionary.

Metadata

{'driver': 'GTiff',
 'dtype': 'uint16',
 'nodata': None,
 'width': 22,
 'height': 28,
 'count': 12,
 'crs': CRS.from_epsg(32622),
 'transform': Affine(30.0, 0.0, 606315.0,
        0.0, -30.0, -2740815.0)}

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