To my understanding of the code, if a path is supplied to the gen_zonal_stats function, the rasterio.read function is called once per target-geometry. This can cause many slow read actions. In cases where all geometries are close together, a single read to a memory-array and subsequent partial reads from the array would be beneficial. Of course the library cannot decide when to use which approach as a single read may also be too big for the memory (or the data to sparse to gain real benefit).
Would you be interested in a flag like read_once that allows users to specify that they want the whole raster (clipped to the bounds of the target geoms) read into an array and then use the array approach?
To my understanding of the code, if a path is supplied to the
gen_zonal_statsfunction, therasterio.readfunction is called once per target-geometry. This can cause many slow read actions. In cases where all geometries are close together, a single read to a memory-array and subsequent partial reads from the array would be beneficial. Of course the library cannot decide when to use which approach as a single read may also be too big for the memory (or the data to sparse to gain real benefit).Would you be interested in a flag like
read_oncethat allows users to specify that they want the whole raster (clipped to the bounds of the target geoms) read into an array and then use the array approach?