0

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?

Disa
  • 1
  • I little more code will be brilliant... – A. Herlas Oct 11 '22 at 14:14
  • Can you include detailed information showing the coordinates/extents of the `dem` and `geom` data. There's a high chance that something is wrong with the coordinate system/projection, making them either not overlap or be completely different scales. – Damien Ayers Oct 13 '22 at 04:19

0 Answers0