I have a script that used to work for calculating zonal statistics (median), but now I get the AttributeError: 'DatasetReader' object has no attribute 'affine'. Here is my code:
with rasterio.open(f'{project_data}/ras.tif') as raster:
array = raster.read(1)
affine = raster.affine
stat = zonal_stats(f'{project_data}/Lila.shp', array, affine=affine,
stats=['median'], geojson_out=True)
result = {"type": "FeatureCollection", "features": stat}
outname = f'{project_data}/files/Lala_test.geojson'
with open(outname, 'w') as outfile:
json.dump(result, outfile)
I unsucessfully tried to install rioxarray yesterday with Anaconda, and I am using an virtual conda - environment (Python 3.8 Interpreter), could that be the problem? If yes, how can I fix that? I am on windows 10...