I am using the zonal_stats
function in the rasterstats
package to calculate summary statistics from GeoTiffs containing vegetative index values. The summary statistics come out fine, however with each iteration of the zonal_stats
function I run, I encounter the warning UserWarning: Setting nodata to -999; specify nodata explicitly warnings.warn("Setting nodata to -999; specify nodata explicitly")
When I created each GeoTIFF file, I set the nodata value as outband.SetNoDataValue(np.nan)
. Each geotiff is opened and VI statistics calculated with:
raster = [FILE PATH]
raster = rasterio.open(raster, mode='r')
# Assign raster values to numpy nd array
vi_array = raster.read(1)
affine = raster.transform
# Calculate VI stats
zonal_stats = rasterstats.zonal_stats(shapefile, vi_array, affine=affine,
stats="mean count std median",
geojson_out=True)
How does one get rid of this warning message?