Zonal Statistics as Table: Overlapping Polygons: Solution Required

24473
63
08-09-2011 07:01 AM
PeterWilson
Occasional Contributor III
I'm currently using ArcGIS 10 SP2 on Windows 7 64bit. I'm working on a very large railway alignment design project and need to generate "Average Catchment Slopes" for each watershed. The problem that I have is that the "Zonal Statistics as Table" tool does not process overlapping polygons. It's mentions in the help that if the polygons overlap, that should be processed interactively to overcome this. I haven't been able to find any supporting documentation to achieve this. Just a note, I have over 600 watersheds that I need to process and a manual process will not be possible if I'm to meet my deadline. Any advice will be appreciated.

Regards
63 Replies
LuciaBarbato
New Contributor III
Thanks for the quick reply!  We will work on it today and report back.
0 Kudos
LuciaBarbato
New Contributor III
We just set up and started running the feature statistics to table tool. We checked the box to process overlapping features. After 14 minutes, 31 features of 79,615 were processed. We figure that's about 600 hours of processing. We read in previous posts about setting up scratch workspaces by modifying the code, but have reached the end of our expertise. We just wanted to let you know how things worked out for us. We will continue our work and deal with the overlapping polygons at a later time. Thanks for letting us try your code.
0 Kudos
DanielSheehan
New Contributor II

@lbarbato

I actually fount this solution, to create vector points, to run a whole lot faster. Essentially, Zonal Stats just uses the cell centroid so why not just convert it to points and do intersect and then summary stats.



So now I'm thinking of just converting my Kernel Density surface (the file I want to do Zonal Stats for) to a point file and just using Summary Statistics after an intersect of polygons to points. I'm just exhausted using Zonal Stats for 2 reasons, it keeps crashing using iterators AND 13-character limits for file names (I had to reprocess work to create unique IDs that took a whole day b/c my unique IDs were 15 characters long).

Do you see any reason not to do this vector version of Zonal Stats? And how stable is your tool that you don't feel comfortable putting up on the forum? I may not be of help testing b/c I'm not much of a python programmer (I'm self taught modelbuilder and know very little python and even less VBA).

Danny

Danny
0 Kudos
StevenDempsey
New Contributor
Take a look at the attached tool.   It will allow you to do zonal statistics as table on overlapping polygons.  you can add this tool directly to ArcToolbox.

Jamie


How do you get this installed into ArcMap10??
0 Kudos
curtvprice
MVP Esteemed Contributor
How do you get this installed into ArcMap10??


In Arc 10, you can just access the toolbox directly in the catalog window. No need to "add toolbox".
0 Kudos
SueClark
New Contributor II
I was working on separating a feature class with overlapping polygons  into a minimal set of feature classes with  non-overlapping polygons when I was asked to work on a solution for the Zonal Statistics problem described here.  I came up with a different solution, probably because I was working on this from a different angle.  The routine I wrote is recursive and uses spatial join. 

I'm only attaching the python code.  Feel free to use it or modify it for your needs.


Sue
0 Kudos
SueClark
New Contributor II
I uploading the full tool  to arcgis online, http://www.arcgis.com/home/item.html?id=b859b33c616a47d2b99b5e133942db02

Sue
0 Kudos
SueClark
New Contributor II
I was working on separating a feature class with overlapping polygons  into a minimal set of feature classes with  non-overlapping polygons when I was asked to work on a solution for the Zonal Statistics problem described here.  I came up with a different solution, probably because I was working on this from a different angle.  The routine I wrote is recursive and uses spatial join. 

I'm only attaching the python code.  Feel free to use it or modify it for your needs.


Sue


The code wasn't as efficient as I would like, so I rewrote it.  It's no longer recursive.  Although you might have to think about the methodology a bit, I think the code is a little clearer.  The code requires one spatial join and uses the joined id field to seperate the features into non-overlapping groups.
0 Kudos
curtvprice
MVP Esteemed Contributor
Neat, Sue! I will definitely look into this - thanks for sharing your code.

I noticed something you may be interested in:

Here's your (nicely documented) code:
    # Note the select string will be different depending on the workspace
    desc = arcpy.Describe(env.workspace)
    if desc.extension == 'mdb':
        selStr = "[" + fCount + "] = " 
    else:
        selStr = "\"" + fCount + "\" = "


Esri has provided us a more

'>robust arcpy method
to solve this problem:

    # Note the select string will be different depending on the workspace
    dfCount = arcpy.AddFieldDelimiters(env.workspace,fCount)
    selStr = dfCount + " = "
0 Kudos
SueClark
New Contributor II
Thanks Curt!  I'm still relatively new to arcpy.  The code I published is a special case.  I've been trying to make it run as a fully implemented tool in my limited spare time.  Right now I'm having some problems getting the tool to run with a FGDB raster.

Sue
0 Kudos