python-rasterstats icon indicating copy to clipboard operation
python-rasterstats copied to clipboard

zonal_stats function returns 'infinity' value

Open shubham-scisar opened this issue 5 years ago • 3 comments

zonal_stats function returns infinity when calculating mean for some geometries.

shubham-scisar avatar May 06 '20 08:05 shubham-scisar

zonal_stats function returns infinity when calculating mean for some geometries.

If there's an inf within the portion of the raster delineated by the polygon, that seems mathematically correct.

ircwaves avatar May 06 '20 13:05 ircwaves

zonal_stats function returns infinity when calculating mean for some geometries.

If there's an inf within the portion of the raster delineated by the polygon, that seems mathematically correct.

There is no inf value in the raster.Also, I think inside the main script of rasterstats where mean is being calculated as float(masked.mean()), if it is changed to np.mean(masked.astype('float64')) (as the data type of my raster is float32, the problem vanishes). So, I think this limitation of numpy should be taken careof in the versions to come.

shubham-scisar avatar May 06 '20 14:05 shubham-scisar

@shubhamsharma1609 can you provide a minimal example with code and data to reproduce this?

perrygeo avatar May 11 '20 14:05 perrygeo