0

I am currently trying to use zonal_stats of the rasterstats package to get zonal statistics of processed satellite images. The data is stored as .img-format and i have a shapefile containing 1 polygon to test things.

from rasterstats import zonal_stats
IMG = 'S1A_IW_GRDH_1SDV_20181104T054742_20181104T054807_024434_02AD7C_F5E1_pre.data\\Ratio.img'
SHP = 'Lake2.shp'
stats = zonal_stats(SHP,IMG,stats = "*")

When I run the code I get the following error message:

AttributeError: 'rasterio._io.RasterReader' object has no attribute 'mask_flag_enums'

Does anyone know how I could work around this? Previously I used ArcPy to get this done but I do not want to use it in further projects since not everyone has access to it.

2
  • Try specifying full paths to raster and shapefiles.
    – BERA
    May 6, 2020 at 10:34
  • @BERA I did, but it did not help. Thanks for the suggestion.
    – Felix
    May 6, 2020 at 10:44

1 Answer 1

0

As of now, I think it was a problem in my setup. I reinstalled Anaconda and created a new environment using the data and it worked. Might have to do something with the fact that anaconda was installed on a HDD-Drive with FAT32-System instead of my SSD with NTFS. Fat32 seems not to be able to be used with files >4GB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.