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.

  • your problem is a problem because of the size of your dataset. The answers (and the link that you propose) are correct but you'll have memory issues. Maybe you could first try an integrate on your data with a few hundred meters (based on the expected precision) to avoid the creation of billions of sliver polygons). Make sure to work on a copy to because it will modify your data. – radouxju Oct 23 '14 at 12:41
  • 1
    Divide our shapefile into regional shapefiles, then run the analysis on the regional shapefiles, then dissolve them to get the full file again. – til_b Oct 23 '14 at 12:47
  • I tried to clip this shape with just one country but I got the error 999999 back. – Nora Oct 23 '14 at 13:31
  • 1
    Have you looked at the Dice tool to reduce the complexity of your polygons? Also if you are getting a 999999 error just trying to clip your data have you tried the check geometry tool to see if throws up any insight? – Hornbydd Oct 23 '14 at 15:47
  • 2
    I did a partial Geometry check on the data and there are a lot of self-intersections. I would suggest 1. Ensure maximum RAM use and large pagefile 2. repair geometry 3. If necessary, simplify polygons 3. subset data to 1/3s or 1/4s (or whatever is necessary) 4. Run Union-Dissolve-Rasterize workflow as in this answer 5. Sum the rasters. – Cotton.Rockwood Oct 27 '14 at 17:18

I would recommend using the custom Count Overlapping Polygons tool.

enter image description here


This sample contains a toolbox with one tool, Count Overlapping Polygons. Given a feature class or layer containing overlapping polygons, outputs a new feature class with the overlaps removed and a Join_Count field containing the number of overlapping polygons.

  • I also tried this, and it is not working for my shp (too big). thanks for answering – Nora Oct 23 '14 at 12:48

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]] = [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.

  • @ Nxau: Ok, I guess I made a mistake to explain how the result should look like. It should be a shape where you have new polygons out of the overlapping ones. For example in your picture the circles 4 and 5 are overlapping. The new shape should have three polygons. (Union is not working for this big shape). The overlapping area should have the value 2 in a field and the rest of the circles 4 and 5 should have the value 1 in this field. So in the end there should be a shapefile where you can see how many bird species are found at the same place. Thanks for your script! – Nora Oct 23 '14 at 13:07

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

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

  • Yes, I already tried the approach from the link. But to use union is impossible for this shp. Trying the Spatial Join I got this back: ERROR 000426: Out Of Memory. – Nora Oct 23 '14 at 12:10
  • I'm running it on a machine with just 4GB RAM and had about 5 times as many features, so I'm surprised it's not working with a much lower number. You may have too many vertices in your data (mine was about 60MB; how big is your .shp file?). Try generalising it. – GIS-Jonathan Oct 23 '14 at 13:20
  • If just the shp is in a fgdb the fgdb has 1,73 GB. In a folder the shape has 2,00GB. – Nora Oct 23 '14 at 13:45
  • I have used this data set as well and I think that many of the problems arise because quite a few of the polygons have many parts. That in conjunction with the resolution makes this a very memory intensive task. – Cotton.Rockwood Oct 27 '14 at 15:34
  • @Cotton.Rockwood: And you find the solution in R, right? I think of using the toolbox 'Count Overlapping Polygons' with the input of 500 polygons (33 selections) than polygon to raster with the value "join count" and at the end calculate raster (ModelBuilder) . It takes a long time ... – Nora Oct 28 '14 at 10:03

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.

Hope this helps!

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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