I need help getting the merge to work on this script. I currently do not get an error but features don't merge.
I need the features of wp1 Mile and wp2 Mile to merge into one feature but merge based on the Buff_DIST feild, the attributes with "1" will be one and the ones with "2" will be another.
I think the reason why i get 12 features in the mile1_2 is because there is multiple parcels in the SP
the code i am working with. Should i be using a Dissolve and if so how we i use the dissolve with my current code?
distances = ["1 Mile", "2 Mile"]
for distance in distances:
outfile = "wp%s" % distance
arcpy.Buffer_analysis(SP, outfile, distance, "FULL", "ROUND", "", "BUFF_DIST")
out = arcpy.env.workspace
lyr = ["wp1 Mile", "wp2 Mile"]
#shplist = arcpy.ListFeatureClasses(lyr, "Polygon")
arcpy.Merge_management(lyr, os.path.join(out, "mile1_2"))
Solved! Go to Solution.
import arcpy
distances = ["1 Mile", "2 Mile"]
for distance in distances:
outfile = "wp%s" % distance
arcpy.Buffer_analysis(SP, outfile, distance, "FULL", "ROUND", "", "BUFF_DIST")
out = arcpy.env.workspace
lyr = ["wp1 Mile", "wp2 Mile"]
#shplist = arcpy.ListFeatureClasses(lyr, "Polygon")
merge_out_path = os.path.join(out, "mile1_2")
arcpy.Merge_management(lyr, merge_out_path)
dissolve_out_path = os.path.join(out, "mile1_2_dissolved")
arcpy.Dissolve_management(merge_out_path, dissolve_out_path, ["BUFF_DIST"])
This will give you the geometry you want.
You need to work out how to combine the attributes yourself if needed. (e.g. the features in 1 mile, you have multiple Account Numbers + Pins that you now want to store in 1 row.
do it manually on a copy of the file...
start with Dissolve—Help | ArcGIS for Desktop
then go to the Using the Results window—Help | ArcGIS for Desktop
and copy the result as a python snippet
You will then have the syntax and know if it will work in code
import arcpy
distances = ["1 Mile", "2 Mile"]
for distance in distances:
outfile = "wp%s" % distance
arcpy.Buffer_analysis(SP, outfile, distance, "FULL", "ROUND", "", "BUFF_DIST")
out = arcpy.env.workspace
lyr = ["wp1 Mile", "wp2 Mile"]
#shplist = arcpy.ListFeatureClasses(lyr, "Polygon")
merge_out_path = os.path.join(out, "mile1_2")
arcpy.Merge_management(lyr, merge_out_path)
dissolve_out_path = os.path.join(out, "mile1_2_dissolved")
arcpy.Dissolve_management(merge_out_path, dissolve_out_path, ["BUFF_DIST"])
This will give you the geometry you want.
You need to work out how to combine the attributes yourself if needed. (e.g. the features in 1 mile, you have multiple Account Numbers + Pins that you now want to store in 1 row.