generating zonal stats from raster data
Note:This module is a thin layer on top of the rasterstats
package to make its interface more compatible with the other geowrangler modules (e.g. vector zonal stats)
import matplotlib.pyplot as plt
import numpy as np
import rasterio
with rasterio.open(terrain_file) as src:
data = src.read(1)
data_crs = src.crs
data_bounds = src.bounds
print(data.shape, data_crs, data_bounds)
simple_aoi.total_bounds
ax = plt.imshow(data, cmap="pink")
ax = simple_aoi.plot(facecolor="none", edgecolor="blue")
%%time
results = create_raster_zonal_stats(
simple_aoi,
terrain_file,
aggregation=dict(func=["mean", "max", "min", "std"], column="elevation"),
extra_args=dict(nodata=np.nan),
)
results