I have a polygon feature class contains groups of adjacent polygons and the question is how to create a multipart polygon for each group of the adjacent polygons without dissolving it using python scripts.
Is this a task that you are going to repeat multiple times?
Is it part of a workflow for something much larger?
Is it safe to assume that this is just a sample of a huge dataset making the manual method of doing this inappropriate?
Do you have anything within your attribute table that indicates adjacency?
Just need to know how far along you are in your script development. If you have some code you are working with, posting would be useful since people won't have to reinvent the wheel.
This task only for time and i do it rarely,
Not a in a workflow,
The manual method of doing this inappropriate as it dissolve them and i want each group of the adjacent polygons to be one feature one record as a multipart polygon but not dissolved,
There are common attributes between the adjacent polygons.
I didn't used a script so far, I am asking about it
... and the common attributes need to be summed in some way or can you just to the attributes of the first part and assign it to the output multipart feature?
All attributes should be assigned to the output multipart feature.
... the question remains: you are combining multi features (multi records) into a single record. Is it valid that a single (random) record is used to assign to the output multipart feature?
maybe it would be easier to attach the features you used in the picture. This will enable us to see what problems you may run into ...
I hacked some code to create the multipart as described before, but I noticed a strange effect. I started a new thread to confirm this undesired behavior: Re: Create a multipart polygon with arcpy and it appears that what you are looking for is not possible as Darren Wiens indicated in the other thread.
...any parts that share an edge will be merged into a single part (source: ArcGIS Help 10.1)
Below the python code that I had so far, but this does not give you the result you want, since it is not possible.
import arcpy, os
arcpy.env.overwriteOutput = True
fc_in = r"D:\Xander\GeoNet\HouseMultiPart\data.gdb\houses"
fc_dis = r"D:\Xander\GeoNet\HouseMultiPart\data.gdb\housesDissolved3"
fc_out = r"D:\Xander\GeoNet\HouseMultiPart\data.gdb\houses_MPs13"
lst_flds = arcpy.ListFields(fc_in)
ws, name = os.path.split(fc_out)
arcpy.CreateFeatureclass_management(ws, name, "POLYGON", fc_in, spatial_reference=fc_in)
##for fld in lst_flds:
## if len(arcpy.ListFields(fc_out, wild_card=fld.name)) == 0:
## arcpy.AddField_management(fc_out, )
# loop through dissolved features
flds = ("SHAPE@")
with arcpy.da.InsertCursor(fc_out, flds) as curs_out:
with arcpy.da.SearchCursor(fc_dis, flds) as curs_dis:
for row_dis in curs_dis:
pol_dis = row_dis
# select features that overlap with dissolved feature
arcpy.SelectLayerByLocation_management("lyr_in", "INTERSECT", pol_dis)
with arcpy.da.SearchCursor("lyr_in", ("SHAPE@", "OID@")) as curs_in:
lstParts = 
for row_in in curs_in:
pol_in = row_in
oid = row_in
for part in pol_in:
lstPnt = 
for pnt in part:
# construct multipart
# write the multipart to output fc
pol_out = arcpy.Polygon(arcpy.Array(lstParts))
del curs_dis, curs_in, curs_out, row_dis, row_in
Might be best to dissolve the polygons not creating multiparts (yep the opposite of what you want) to a tmp featureclass and then loop through these features, select the original polygons, and add the polygons to parts of the new polygon to be created.
You may also want to consider moving this thread to the Python place:
(see: What are Places? )
Retrieving data ...