# calculate zonal statistics using overlapping polygons

7345
14
05-15-2015 09:35 AM
New Contributor II

Hello! I'm trying to calculate zonal statistics with a grid as input and overlapping circles in a feature class as areas. As I understud the software is converting the feature class with the polygons in a raster file in the background and clips the polygons. Can I avoid this somehow or is there an other possibility to extract this spatial information from the grid? What I would need is the number of cells with specific values within a 2000m radius around points. Thanks!

Tags (3)
1 Solution

Accepted Solutions
MVP Honored Contributor

What type of feature class are you working with? Where clauses are data-specific (see the help for Make Feature Layer, where clause section). My example used a shapefile - fields are enclosed by double quotes. File GDB fields have no quotes. Personal GDB fields are enclosed by []. A nice way to figure it out is to run Make Feature Layer once through the normal tool dialog to figure out the syntax. Once you get it to work once, you can export the result from the results window to a Python snippet and inspect the syntax more fully in a text editor or IDE

14 Replies
MVP Frequent Contributor

So if I understand your dilemma correctly, the issue is the overlapping polygons (circles) not being processed correctly by the Zonal Statistics tool.  If that is the case, the help for the tool offers this explanation and resolution for this issue:

• If the zone feature input has overlapping polygons, the zonal analysis will not be performed for each individual polygon. Since the feature input is converted to a raster, each location can only have one value.

An alternative method is to process the zonal statistics iteratively for each of the polygon zones and collate the results.

Source:  ArcGIS Help 10.1

So the solution then would involve iterating the Zonal Statistics tool for each individual polygon.  Common ways to accomplish this include Python and Modelbuilder (using an Iterator).

Chris Donohue, GISP

(EDIT:  fixed typos]

MVP Honored Contributor

In addition to Chris' comment about processing zones individually, it sounds like you may be more interested in the Tabulate Area tool (which will list the cells in each class), rather than Zonal Statistics (which performs some numerical summarization of your classes, like mean, range, etc.).

MVP Esteemed Contributor

Esri has provided an enhanced Zonal Statistics and Tabulate Area tools that handle overlapping polygons in the Spatial Analyst Supplemental tools.

I have posted a toolbox on ArcGIS Online that does both zonal statistics of tabulations of categorical data from points. (It does the buffers for you).  It also includes a tool that will weed points if you don't want to run them one at a time, which can be slow for thousands of points:

NAWQA Area-Characterization Toolbox

For a lot more discussion on this, see:

New Contributor II

hi, thank you very much for your aswers and sorry for my late replay.

You are right, i need the Tabluate Area tool to get the results I want. But there is still the problem with the overlapping polygons. For sure I can calculate single circle areas and summarise then the results in one table, but I have to calculate >1000 points, so a tool would be nice to have.

@Curtis Price thank you for your tipps.  I tried now the spatial analyst supplemental tool on ArcGIS 10.3.

If I use the Tabulate Area 2 tool on three not overlapping circles it's working perfectly. Then I tried it on three overlapping circles and it does the same as the standart Tabulate Area tool. Its not calculating the entire area. Maybe somebody has a hint what could be the problem?

I tried also the NAWQA Area-Characterization Toolbox, but its alwas producing a error "the extent my input featurs is not exact"... No idea what could be wrong with them.

Thanks!

Hannah

MVP Honored Contributor

Here is how you can do it with Python. Requires Spatial Analyst. This example uses an overlapping zone feature class called "buffer_1000" (must have "FID" field), class raster called "raster" (must have "Value" field), and outputs one table for each feature in the zone feature class called "outTable1", "outTable2", etc. You can then run Merge to consolidate these output tables. Of course, change the feature class names to suit your data.

`>>> zoneFC = "buffer_1000"... raster = "raster"... with arcpy.da.SearchCursor(zoneFC,"OID@") as cursor:...    for row in cursor:...        arcpy.MakeFeatureLayer_management(zoneFC,"tempFL","\"FID\"=" + str(row[0]))...        rast = arcpy.sa.TabulateArea("tempFL","FID",raster,"Value",r"in_memory\outTable" + str(row[0]))`
New Contributor II

Thank you very much for the code.

I changed the file names but he reclaims a syntax error in row 6

>>> zoneFC="POIzone_Random"

... raster="Allminerals_Extension.bmp"

... with arcpy.da.SearchCursor(zoneFC,"POI_Nr") as cursor:

...     for row in cursor:

...         arcpy.MakeFeatureLayer_management(zoneFC,"tempFL","\"POI_Nr\"=" + str(row[0]))

...         rast=arcpy.sa.TabulateArea("tempFL","POI_Nr",raster,"Value",r"E:\Projekte\Coop_Meyer\outTable" + str(row[0]) >>>

...

Parsing error SyntaxError: invalid syntax (line 6)

MVP Honored Contributor

There was a copy/paste error in there - I've updated above. The final line should end with this, not >>>: str(row[0]))

`rast = arcpy.sa.TabulateArea("tempFL","FID",raster,"Value",r"in_memory\outTable" + str(row[0]))`
New Contributor II

Thanks!

I'm VERRY sorry but I have no idea of coding as you my have noticed

Now it reports a error in line 7. But line 7 is empty...... is there somethin I have to write to end the code?

>>> zoneFC="POIzone_Random"

... raster="Allminerals_Extension.bmp"

... with arcpy.da.SearchCursor(zoneFC,"POI_Nr") as cursor:

...     for row in cursor:

...         arcpy.MakeFeatureLayer_management(zoneFC,"tempFL","\"POI_Nr\"=" + str(row[0]))

...         rast=arcpy.sa.TabulateArea("tempFL","POI_Nr",raster,"Value",r"E:\Projekte\Coop_Meyer\outTable" + str(row[0])

...

Parsing error SyntaxError: invalid syntax (line 7)

MVP Honored Contributor

No problem. Python requires proper indentation. The first line has no indentation - it is three '>' characters and one space. The next line is three '.' characters and one space. Both of these are at indentation level zero. Same with line three. Line 4 is indented by 4 spaces, to indicate it is inside the 'with' block. Line 5 is indented by 8 spaces, to indicate it is inside both the 'for' and 'with' blocks. Line 6 (rast=...) should be indented exactly the same as Line 5 - it should be inside both the 'for' and 'with' blocks.