# Raster statistics along polygon edges

I would like to summarize raster statistics along the edge of each parcel/polygon in a shapefile.

For each parcel shown below in yellow, I would like to calculate the average, min and max value of the raster along the edge bordering the polygon. There will likely be 100,000 polygons that need to be summarized.

Note that the polygons will never overlay the raster, they are only adjacent and share an edge. Ideally those stats could be joined directly to the parcels.

I have ArcGIS 10.2.2 with Spatial Analyst and am comfortable scripting in Python if that is a good path.

As you are not always exactly adjacent, I would take a small buffer along each polygon, then you can use "zonal statistics as a table" with those buffers and join the table to your polygons. Use the "DATA" option to ignore your nodata values.

Edit : Exact solution assuming that the white in the illustration is NoData and the polygons are adjacent to the the raster with values of interest.

1) create a raster based on the NoData of your raster (raster calculator > Con(IsNull("raster"), 1, 0) )

2) Expand the raster values of 1 by one pixel (using "expand")

3) substract the second raster with the first raster (raster calculator > "rasterExpand" - "binaryRaster"). You should have a line of 1 along the edge of the raster.

4) create distance allocation for the polygons

5) multiply the distance allocation raster by the boundary raster

6) compute zonal stat

• The parcels look adjacent to me (according to the OP they "share an edge"), and therein lies the difficulty: zonal statistics (in its native form) is just not going to work, because polygons share zones. Commented Sep 8, 2014 at 15:02
• Thanks for taking a look @whuber - They are indeed adjacent and I believe the buffer method described by radouxju will be the best fit. Commented Sep 8, 2014 at 15:32
• The problem is it won't work, because the polygon boundary buffers will overlap. Zonalstats has to rasterize the zones, which is not possible to do with overlapping regions. You can use solutions that loop through zone features (but then there's no need to buffer them in the first place) or, if that's too slow, you can preprocess the polygons to break them into non-overlapping arcs, do the zonal stats on those arcs, join the results back to the polygons of which the arcs are constituents, and perform a statistical summary. Commented Sep 8, 2014 at 15:36
• @whuber from my understanding based on the illustration, the polygon share an edge with the raster. There could be a little overlap where two polygons touch, but very limited. I've edited my answer with a longer but better solution. Commented Sep 8, 2014 at 18:31
• There may be some miscommunication here. I do not see anything that could be construed as the limit of the raster--this seems to be an inset from a larger map. One clue is that the black lined boundaries of the yellow polygons do not appear along the bottom or right of the illustration. The issue is not that polygon boundaries are aligned with raster limits, but that polygons can share portions of their boundaries, rendering a straightforward application of zonal stats ineffective: "share an edge" in the question refers to two polygons, not to a polygon and a raster. Commented Sep 8, 2014 at 18:34