I want to mask some polygons onto a raster image with rasterio.mask but all I get are nan values. I have checked that they are in the same coordinate system and in GIS the layers overlap. What can be wrong? For my raster image i have used
dem = rasterio.open(DEM, crs='EPSG:3006')
and my polygons are derived from a dataframe (when i plot them they look alright). But when i try to use mask
geom_dem, info = mask (dem, [geom], crop=True, invert=False, all_touched=False)
the result geom_dem becomes:
array([[[nan, nan, nan, ..., nan, nan, nan],
[nan, nan, nan, ..., nan, nan, nan],
[nan, nan, nan, ..., nan, nan, nan],
...,
[nan, nan, nan, ..., nan, nan, nan],
[nan, nan, nan, ..., nan, nan, nan],
[nan, nan, nan, ..., nan, nan, nan]]], dtype=float32)
I have checked and there are no element with a value other than nan.
What could be wrong and how is it fixed?