2

I am using buffer tool on large complicated network (260,000 features) line shapefile to create an area shapefile. This area shapefile somehow has to be dissolved to a single multipart shapefile.

Code used:

arcpy.Buffer_analysis(featureLayer , temp2, "0.5 Feet", "FULL", "FLAT", "ALL") 
arcpy.Dissolve_management(temp2, temp3, "", "", "", "")
arcpy.MultipartToSinglepart_management(temp3, outputLayer)

Problem: The dissolve after buffer for some reason does not create a single multipart feature. It creates many multipart features that can't be dissolved with each other. I tried to dissolve it five consecutive times, it produced the same result.

Is there any way to dissolve all these features to create a single multipart feature?

  • Do the undissolved parts overlap? – Emil Brundage Dec 7 '17 at 18:15
  • Yes for most part, if they were not overlapping, they were at least touching each other. – pnkjmndhl Dec 7 '17 at 18:17
  • Tryarcpy.Buffer_analysis(featureLayer , temp2, "0.5 Feet", "FULL", "FLAT", "NONE") (different dissolve type for the buffer). Worth a shot. – Emil Brundage Dec 7 '17 at 18:17
  • setting to "NONE" doesn't work either. Infact creates the same results. – pnkjmndhl Dec 7 '17 at 18:36
  • 1
    I had similar issue, with dataset split by straight lines. Ended up merging them in editing mode. Some sets are simply too big... – FelixIP Dec 7 '17 at 20:27
1

You may be running into a geometry limitation of the shapefile format (Geoprocessing considerations for shapefile output).

You could try running the Buffer analysis to an in_memory feature class then CopyFeatures to a shapefile on disk.

arcpy.Buffer_analysis(featureLayer , r"in_memory\temp2", "0.5 Feet", "FULL", "FLAT", "ALL")
arcpy.CopyFeatures_management(r"in_memory\temp2", "Final_Output.shp")

If you hit the geometry limitation again you'll probably have to use a Dice to subset the polygons in some way or a Generalize.

  • Tried this, didn't work, same results. I have not tried Dice. – pnkjmndhl Dec 7 '17 at 20:54
  • The last line of your original code block is going to break the multipart features into single parts...is that intentional? Why create a single multipart feature only to break it up again? This seems to be contrary to your requirement of "This area shape file somehow has to be dissolved to a single multipart shapefile." – Dan Dec 7 '17 at 21:13
  • Yes, when I use that command, all the touching features are grouped together. That's my main objective. If you got a way to group all the touching features, that would work too. – pnkjmndhl Dec 7 '17 at 21:20
  • While, the issue i have addressed in the question is due to the size of the dataset. I have tried with smaller data and it works. – pnkjmndhl Dec 7 '17 at 21:22
1

Create an new feature class with the same spatial reference as the polygons you are trying to dissolve. Then use a search cursor to pull geometry objects. For each row in your buffer feature class, perform a union to create a single feature.

import os

arcpy.Buffer_analysis(featureLayer , temp2, "0.5 Feet", "FULL", "FLAT", "ALL") 
#get path and file name of temp3
temp3path, temp3name = os.path.split (temp3)
#create new feature class
arcpy.CreateFeatureClass_management (temp3path, temp3name, "POLYGON",
                                     spatial_reference = temp2)
#iterate buffer attributes, pull geometries
with arcpy.da.SearchCursor (temp2, "SHAPE@") as curs:
    for geom, in curs:
        try:
            #union current geom with all prior geoms
            unionGeom = geom.union (unionGeom)
        except NameError:
            #first geometry, just assign it as union geometry variable
            unionGeom = geom

#insert dissolved geometry into created feature class
with arcpy.da.InsertCursor (temp3, "SHAPE@") as curs:
    row = (lastGeom,)
    curs.insertRow (row)

...or without a new feature class, just dissolving a feature class with multiple features into a single feature:

#iterate buffers, get geometries
with arcpy.da.UpdateCursor (temp2, "SHAPE@") as curs:
    for geom, in curs:
        try:
            #union current geom with all prior geoms
            unionGeom = geom.union (unionGeom)
        except NameError:
            #first geometry, just assign it as union geometry variable
            unionGeom = geom
        #delete row
        curs.deleteRow ()

#create insert cursor
with arcpy.da.InsertCursor (temp2, "SHAPE@") as curs:
    #insert final union geometry
    curs.insertRow ((unionGeom,))
  • I tested this method myself and it sadly produced a MemoryError. – Emil Brundage Dec 8 '17 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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