10

I have a shapefile with 16,400 polygons. Each polygon shows the expansion of a bird species for the whole world.

enter image description here

Now I have to count the overlapping polygons. I tried it with union and dissolve (count the union), but the union is not working for so many polygons.

Then I tried to clip continents, but this is also not working because of the huge number of polygons. Moreover I tried this method , also without success.

Therefore I'm asking you I there is a way to count overlapping polygons if 16400 polygons are in one shapefile?

I'm working with 10.0 and can work with 10.2. An ArcPy solution is also wonderful.

At the moment I am thinking about creating a fishnet and iterate over the rows of the shp with the 16400 polygons and write 1 to a value field of a fishnet cell if the polygon is in this cell and than take the next row (polygon) and if this is also in the fishnet cell count +1.

But I don't know if this is a good solution and how to realize it. Or I have to learn R to use this approach.

The result: It should be a shape where you have new polygons out of the overlapping ones and a field where the overlaps are counted.

So in the end there should be a shapefile where you can see how many bird species are found at the same place.

0

5 Answers 5

10

I would recommend using the Count Overlapping Features (Analysis) tool.

Generates planarized overlapping features from the input features. The count of overlapping features is written to the output features.

enter image description here

0
6

A very simple method is:

  1. Union the shapefile with itself;
  2. Convert multipart output to single part;
  3. Use the spatial join tool to count overlaps (use the ARE_IDENTICAL_TO match option);
  4. Symbolize using the join_count field.

enter image description here

5

Using arcpy geometry tokens, you could try something like this:

enter image description here

import os
import arcpy

arcpy.env.workspace = r"" #path to workspace
arcpy.env.overwriteOutput = 1

polygon_fc = r"" #path to polygon fc

base = [row for row in arcpy.da.SearchCursor(polygon_fc,["OID@","SHAPE@"])]
compare = base

overlaps_stats = {}

for b in base:
    for c in compare:
        if b[1].overlaps(c[1]):
            #print "{0} overlaps {1}".format(b[0],c[0])
            if overlap_stats.has_key(b[0]):
                overlap_stats[b[0]].append(c[0])
            else:
                overlap_stats[b[0]] = [c[0]]

for key,value in overlap_stats.iteritems():
    print "Polygon {0}:  Overlaps: {1}.".format(key,len(value))

For the sample data above, the code will return the following overlap counts: enter image description here

The code as is will only return counts for polygons that have at least one overlap.

0
2

I guess you've tried this method: Counting and rasterizing polygon overlaps in ArcGIS Desktop?

16,400 polygons isn't that many. However, one potential solution is to simply do a regular Spatial Join. In the ArcMap toolbox, > Analysis Tools -> Overlap -> Spatial Join.

Set both the target and join features to the same dataset and specify an output. Leave the rest of the settings.

After a few moments you should get back a shapefile that contains a "join count" column. Subtract 1 from this (as obviously each feature should intersect itself), and that should be the number of "overlaps "(actually intersects) for each polygon.

I just performed it on

0
2

I downloaded and tried the "Count Overlapping Polygons" tool. It might work, but it takes an awfully long time (probably because file size, but my input FC only had < 5,000 records).

While I was waiting for that tool to run , I opened up another ArcMap window and it only took a couple quick steps to get what I wanted.

  1. Spatial Join - using the same feature class as Target and Join Features and selecting the "Join One to Many" option.
  2. Dissolve - using the output from the last step. Use the "TARGET_FID" as the dissolve field and for the statistics you can either SUM the "Join_Count" field or COUNT the "JOIN_FID" field.
  3. In the output file from from step 2, use field calculator subtract 1 from the stats field ("SUM_Join_Count", or "COUNT_JOIN_FID") - since each feature intersects itself.

I suggest using this method over the "Count Overlapping Polygon" tool. I started running the COP tool ~ 5 min before starting this Join->Dissolve method and it gave me the result with enough time to write this up before the "Count Overlapping Polygon" tool had even finished.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.