Date
1 - 4 of 4
Numpy error when masking a Landsat image with a polygon [Rasterio 1.0.28]
juliano.ecc@...
Hi folks
I'm having the following errors when I'm trying to mask a landsat image with a kml polygon.
The metadata for scene LC08_L1TP_221077_20190815_20190820_01_T1 is
My code
|
|
Alan Snow
I wonder if you are looking for `from rasterio.features import geometry_mask`?
https://rasterio.readthedocs.io/en/stable/api/rasterio.features.html#rasterio.features.geometry_mask Example code: https://github.com/corteva/rioxarray/blob/83e321c0b3597cc484fb6445d055e4c0ca893f89/rioxarray/rioxarray.py#L934-L1012 Example rioxarray usage: https://corteva.github.io/rioxarray/html/examples/clip_geom.html
|
|
Alan Snow
After looking at the docs, I think you need to remove `.read(1)` as that returns a numpy array and `mask` expects a dataset: https://rasterio.readthedocs.io/en/stable/api/rasterio.mask.html#rasterio.mask.mask
|
|
Juliano <juliano.ecc@...>
Thank you Alan! I remove '.read(1)' and it works.
|
|