Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm creating a model which combines four very large files and dissolves them. At the moment, my workflow uses the Merge tool and then the Dissolve tool. However, I was wondering if using the Union tool and then dissolving would be more or less efficient. I don't need to maintain attributes for my purposes. I just need to create a layer which contains the geometry. The feature classes may overlap each other, and they may also contain overlaps within themselves. As the end result is the same, does anyone know which process would be more time efficient?

Below are screenshots of my workflows:

Merge then Dissolve:

enter image description here

Union then Dissolve:

enter image description here

share|improve this question
    
Have you checked using some test data whether the result from each process is the same? Intuitively I would not expect that to be the case because the Merge help says This tool will not planarize features from the input datasets. All features from the input datasets will remain intact in the output dataset, even if the features overlap. To combine, or planarize, feature geometries use the Union tool. –  PolyGeo Jul 18 '13 at 2:27
    
I don't have any links or test data to back this up, but I can't imagine any way that the Union tool would ever be more efficient — but it has great potential to be considerably less efficient. The Merge tool is essentially a copy-and-paste operation, whereas the Union tool has to perform at least basic computations on the extent of every single feature and make comparisons to other features to determine whether any splitting is necessary. –  nmpeterson Jul 18 '13 at 2:37
    
@nmpeterson I too have no doubt the Merge path will be faster because I believe it will produce a different and much simpler result. I like the question (+1) but want to make sure we are not comparing apples with oranges. –  PolyGeo Jul 18 '13 at 3:07
1  
Since attributes are unneeded, make sure to remove them in the field map (for merge) or ONLY_FID (for union). Also, I third PolyGeo and nmpeterson that merge is faster. –  Paul Jul 18 '13 at 3:11
3  
Another speed improvement is to write your Merged dataset to the in_memory workspace, rather than writing to disk. This is discussed in more detail in Ways to Speed Up Python Scripts Running As ArcGIS Tools –  RyanDalton Jul 18 '13 at 5:00
show 3 more comments

3 Answers 3

up vote 7 down vote accepted

This is a very simplistic test, but I think it shows conclusively that Merge+Dissolve is about 3 times quicker than Union+Dissolve on this dataset, and I believe that as more complex data is thrown at it, the difference will only widen.

import arcpy,time

if arcpy.Exists("C:/temp/test.gdb"):
    arcpy.Delete_management("C:/temp/test.gdb")

arcpy.CreateFileGDB_management("C:/temp","test.gdb")
arcpy.CreateFishnet_management("C:/temp/test.gdb/fishnet1","10 10","10 20","1","1","50","50","#","LABELS","0 0 75 75","POLYLINE")
arcpy.Buffer_analysis("C:/temp/test.gdb/fishnet1_label","C:/temp/test.gdb/fishnet1circles","0.51 Unknown","FULL","ROUND","NONE","#")
arcpy.CreateFishnet_management("C:/temp/test.gdb/fishnet2","10.1 10.1","10.1 20","1","1","50","50","#","LABELS","0 0 75 75","POLYLINE")
arcpy.Buffer_analysis("C:/temp/test.gdb/fishnet2_label","C:/temp/test.gdb/fishnet2circles","0.51 Unknown","FULL","ROUND","NONE","#")

start = time.clock()
arcpy.Merge_management("C:/temp/test.gdb/fishnet1circles;C:/temp/test.gdb/fishnet2circles","C:/temp/test.gdb/fishnetMerge","#")
elapsed = (time.clock() - start)
print("Merge took " + str(elapsed) + " seconds")
arcpy.Dissolve_management("C:/temp/test.gdb/fishnetMerge","C:/temp/test.gdb/fishnetMergeDissolve","#","#","MULTI_PART","DISSOLVE_LINES")
elapsed = (time.clock() - start)
print("Merge and Dissolve took " + str(elapsed) + " seconds")

start = time.clock()
arcpy.Union_analysis("C:/temp/test.gdb/fishnet1circles #;C:/temp/test.gdb/fishnet2circles #","C:/temp/test.gdb/fishnetUnion","ONLY_FID","#","GAPS")
elapsed = (time.clock() - start)
print("Union took " + str(elapsed) + " seconds")
arcpy.Dissolve_management("C:/temp/test.gdb/fishnetUnion","C:/temp/test.gdb/fishnetUnionDissolve","#","#","MULTI_PART","DISSOLVE_LINES")
elapsed = (time.clock() - start)
print("Union and Dissolve took " + str(elapsed) + " seconds")

I ran the test from IDLE using ArcGIS for Desktop 10.1 SP1 and Python 2.7.2 on Windows 7 SP1 and the results were:

>>> 
Merge took 1.82999991257 seconds
Merge and Dissolve took 5.45186011302 seconds
Union took 7.6488681498 seconds
Union and Dissolve took 14.1194398165 seconds
>>>

As you suggested the Dissolve after Union was a bit quicker than the Dissolve after Merge but not enough to overcome the large gap between Merge and Union.

share|improve this answer
    
+1 Thanks for running this analysis! I was wondering what a speed test would look like. –  Aaron Jul 18 '13 at 14:32
    
+1 and accept for doing a test. I didn't have the time to do it myself. –  Fezter Jul 19 '13 at 4:34
add comment

Merge is definitely faster than Union. PolyGeo has already given a test, so I won't talk about that.

What I will try to explain is the reason behind Merge being faster.

When you run a Union Operation, the geometry of the features is used for the Union Operation. Depending on the Topological nature, new features are generated. The attributes too are combined from all the input features. Further more finding the overlapping features and doing this union operation on them is Algorithmically quite CPU intensive.

Compared to this, the Merge process is just a simple collection of all features. No overlap check is done, no union of those geometries is done. Hence in all cases, Merge will always been much faster than Union.

Now coming to the combination of Merge+Dissolve v/s Union+Dissolve:

  • In the Dissolve tool, what happens is that the geometries of all the features that have the same attribute value, are unioned, and then simplified.
  • The output of the earlier Merge tool may not be planerlized (i.e without overlaps) The output of the earlier Union process is planar, i.e. There are guaranteed to be no overlapping polygons.
  • Hence the Simplification of the the union operation within the Dissolve tool may be faster than compared with the output of the Merge tool.

However, with large data, the major part of the time will be taken with the first Union gp process, and hence the time saved in the Dissolve gp operation will pale in comparison to it.

share|improve this answer
    
I suppose my main question is whether the dissolve would be faster after a merge or after a union. Not necessarily whether the merge is faster than a dissolve. –  Fezter Jul 18 '13 at 19:35
    
@Fezter: I have expanded the answer –  Devdatta Tengshe Jul 19 '13 at 3:09
    
I think that answers my question. I am working with large data and I suspected that using a merge-dissolve would be faster in the end than the union-dissolve. You have confirmed that for me. It looks like I'm stuck with waiting an hour and a half... –  Fezter Jul 19 '13 at 4:33
add comment

if your merge/dissolve is taking more than a few minutes, you can speed up the process by deleting the input's spatial index and then processing the merge/dissolve. (the resulting output shapefile will still have a spatial index)

you can do this manually in catalog (shapefile's properties > indexes tab > delete; use add to recreate the spatial index) or with python: arcpy.RemoveSpatialIndex_management() and to recreate it if needed: arcpy.AddSpatialIndex_management()

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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