Select to view content in your preferred language

Zonal Statistics as Table: Overlapping Polygons: Solution Required

28914
63
08-09-2011 07:01 AM
PeterWilson
Frequent Contributor
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
JamieKass
Regular Contributor
If anyone is interested, I developed some functions in arcpy that break up the overlapping features into distinct non-overlapping groups. After the functions are run, one simply has to iterate over all the unique values in the "expl" field and run Zonal Stats on each. This method reduces the time spent iterating considerably, as the number of non-overlapping groups is a mere fraction of the total number of features. Please see the answer with the green check mark.

http://gis.stackexchange.com/questions/32217/explode-overlapping-polygons-to-new-non-overlapping-fea...
0 Kudos
SueClark
Deactivated User
I did finish the tool I was working on. The tool is faster than the individual polygon solution.  Originally I produced 3 different solutions for breaking up the polygons and ended up using two of those methods.  I have uploaded the tool and documented it.

The tool uses Spatial Join and also breaks up the feature class into smaller pieces.

http://www.arcgis.com/home/item.html?id=b859b33c616a47d2b99b5e133942db02



0 Kudos
bodoMalowerschnig
Emerging 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


Thats all I get from this tool.

<type 'exceptions.RuntimeError'>: Row: Field FID does not exist
Failed to execute (StatisticsForOverlappingZones)
0 Kudos
PeterWilson
Frequent Contributor
Thats all I get from this tool.

<type 'exceptions.RuntimeError'>: Row: Field FID does not exist
Failed to execute (StatisticsForOverlappingZones)


Hi everyone

With the release of ArcGIS 10 a list of iterate functions have been added to ModelBuilder. The problem with overlapping polygons for Zonal Statistics is of the past. If you iterate over your features within a feature class and pass each one to zonal statists it works perfectly and writes out the results into a single table. If anyone would like I would gladly post my model.

Regards
0 Kudos
curtvprice
MVP Alum
The problem with overlapping polygons for Zonal Statistics is of the past. If you iterate over your features within a feature class and pass each one to zonal statists it works perfectly and writes out the results into a single table. If anyone would like I would gladly post my model.


I wouldn't say it's a thing of the past. Setting up the model is not trivial for people new to ModelBuilder, especially how you aggregate the results. Please do post your model, IMHO this is a good "real-world" example of how iteration can be used to great advantage in Arc 10.

The tool Sue just posted is better than a brute-force iteration though - it separates your overlapping polygons into non-overlapping groups - if you have thousands of overlapping polygons, this could mean a few hundred iterations instead of thousands.
0 Kudos
PeterWilson
Frequent Contributor
I wouldn't say it's a thing of the past. Setting up the model is not trivial for people new to ModelBuilder, especially how you aggregate the results. Please do post your model, IMHO this is a good "real-world" example of how iteration can be used to great advantage in Arc 10.

The tool Sue just posted is better than a brute-force iteration though - it separates your overlapping polygons into non-overlapping groups - if you have thousands of overlapping polygons, this could mean a few hundred iterations instead of thousands.


Hi Curtis

I agree that using a iterate to deal with the overlapping is a bit of a brute force, but as a suggestion I could alter the tool to only deal with feature that overlap and pass them as single "in_memory" process" to zonal statistics thereby eliminating the amount of iterations required. I'll post my original model tonight when I get home from work as well as an adjusted model to deal with the overlaps only.

Regards
0 Kudos
PeterWilson
Frequent Contributor
As promised

please find attached my Toolbox (ArcGIS 10.0) with attached model that iterates through each feature within a feature class and passes it onto zonal statistics to calculate the average slope for each polygon (Watershed Catchment) and outputs it into a single table.

Please note that I've used the following model to process over 1200 polygons with no problems. It runs pretty quickly.

I'll post the updated model which identifies the overlapping features and processes them separately to minimise the amount of iterates shortly. problems with my internet connection at the office.

Regards
0 Kudos
AbbyFlory
Deactivated User
Hi Sue,

Thanks for sharing your code!  I was wondering though, would you mind explaining the logic behind the following sentence taken from your official tool post under Description > Solution: "If a feature class is spatially joined to itself, the polygon id in the target and join will match in the top-most layer of polygons. This set of polygons will not overlap any other polygons."  I am specifically confused by the phrase "top-most layer of polygons," and how this process produces non-overlapping features. 

I tried manual testing to better understand it, and when I spatially joined a feature class to itself, the output was identical to the original feature class (with the exception of added fields from the join).  Further, joining this back to the original feature class on polygon id did nothing but add more fields - as all the polygons matched/joined because they were all the same as the originals. 

I have reviewed your code and am still stumped by this process.  If you have the time and wouldn't mind going into the logic details, I'd love to understand what's happening here.  I have been trying to implement a similar routine (but not using spatial join) that results in grouping points (via a flag field) into non-overlapping subsets based on either their buffer or distance to other points.  I'm needing it for the Tabulate Area tool, which has the same overlapping areas problem as the Zonal Stats as Table tool.  Any help would be appreciated!  Thanks for your time!

Abby
0 Kudos
AbbyFlory
Deactivated User
I did finish the tool I was working on. The tool is faster than the individual polygon solution.  Originally I produced 3 different solutions for breaking up the polygons and ended up using two of those methods.  I have uploaded the tool and documented it.

The tool uses Spatial Join and also breaks up the feature class into smaller pieces.

http://www.arcgis.com/home/item.html?id=b859b33c616a47d2b99b5e133942db02






Hi Sue,

Thanks for sharing your code!  I was wondering though, would you mind explaining the logic behind the following sentence taken from your official tool post (your link above) under Description > Solution: "If a feature class is spatially joined to itself, the polygon id in the target and join will match in the top-most layer of polygons. This set of polygons will not overlap any other polygons."  I am specifically confused by the phrase "top-most layer of polygons," and how this process produces non-overlapping features. 

I tried manual testing to better understand it, and when I spatially joined a feature class to itself, the output was identical to the original feature class (with the exception of added fields from the join).  Further, joining this back to the original feature class on polygon id did nothing but add more fields - as all the polygons matched/joined because they were all the same as the originals. 

I have reviewed your code and am still stumped by this process.  If you have the time and wouldn't mind going into the logic details, I'd love to understand what's happening here.  I have been trying to implement a similar routine (but not using spatial join) that results in grouping points (via a flag field) into non-overlapping subsets based on either their buffer or distance to other points.  I'm needing it for the Tabulate Area tool, which has the same overlapping areas problem as the Zonal Stats as Table tool.  Any help would be appreciated!  Thanks for your time!

Abby
0 Kudos
Xin_RanDing
Emerging Contributor
Hi

I'm trying to extraction band information from raster images using overlapping buffers. I tried using Jamie's code and it takes a long time. I can't ran Curtis' code. Does anymore have a code that works faster?


Thanks
0 Kudos