Select to view content in your preferred language

Zonal Statistics analog tool that produces a vector layer, not a polygon layer

407
2
08-28-2024 07:35 AM
jmc_123
New Contributor

I have a raster layer with a DEM of difference for two years of LIDAR data. This layer is masked such that the raster cells only appear in circular areas (100-ft radius buffer areas around stormwater outfalls). There are around 3,000 of these circles in the raster layer. I want to create a vector layer with polygons, with each polygon having attributes (mean, sum, and max value) that describe statistics of the raster cells within the boundaries of the polygon. 

The Zonal Statistics tool allows me to calculate mean, sum, max value etc separately for each circular area of cells by using a vector polygon layer as my "Input Raster of Feature Zone Data" input, and using my raster layer as the "Input Value Raster" input. However, the output of the Zonal Statistics tool is a raster, not a vector polygon layer. I know that the "Raster to Polygon" tool allows me to create a polygon layer out of the resultant raster layer, but this process is clunky- it takes a while, forces me to convert my values from floats to integers, and causes me to lose some data because of the way that my polygon input layer is rasterized.

I was wondering if there is a tool that does what Zonal Statistics does, but produces a vector polygon layer (with the statistics as attributes) rather than a raster layer.

Thanks in advance for any wisdom you can provide!

0 Kudos
2 Replies
clt_cabq
Frequent Contributor

I wonder if the Zonal Statistics as Table tool is what you want. Produces the same data as ZS but just as a table as output and it looks like there is an option to join it back to your zone input vector layer.

AdamGaudet
Regular Contributor

QGIS has a zonal statistics tool that spits out a zonal statistics output so simply and easily, and in less processing time than ArcPro (not that it takes that long to process in ArcPro, but I do notice it takes longer, so I am mentioning it in this post). And on top of all this, it appends the results directly to a new output of the input vector layer. (Like why have the middleman of me creating a table to then join this table to my input vector layer?)

See https://docs.qgis.org/3.34/en/docs/user_manual/processing_algs/qgis/rasteranalysis.html#zonal-statis... for a tool summary. There are many good examples out there showing how to use this tool by searching "qgis zonal statistic" or something similar.

What I like most in regards to this tool (and all other tools in QGIS for that matter) is that it will by default produce an output in virtual memory, where the user can quickly check and view results without having to always specify a path to save an output too. (Lots of painful clicking and navigating when trying to put things in folders and geodatabases in ArcPro.) I find when I'm doing a new operation and am not sure of what the exact output might be (though I have an idea of what and how it should look), the default write-to-memory allows me to quickly (oh, so ever so quickly) to run the tool and see what comes out at the other end. If I'm satisfied with my results (they make sense and appear spatially as they should), I simply right-click on the layer and export the in-memory output to disk. (Oh, and did I mention there is zero lag time when opening and closing attribute tables in QGIS, and there is no slow sticky scrolling when moving up and down or left and right through the table?)

0 Kudos