3

I have a single polygon feature class that contains large polygons which represent signal strength. Often times these polygons overlap. I dissolve to get multi-part polygons with a value range of 3 to 8.

What I need to do is "stomp" the feature class to only keep the highest value in a given area. I've tried looping the polygon and creating a temp feature class of each value, then erase/merging from the highest value down, but I get an error if there is a multipart polygon. I wrote in code to explode the multipart feature, but it locks up the pc.

I think the arcpy.update_analysis tool will work, but I need to be sure that it loops from the highest value to the lowest.

Here's the code from my first attempt:

with arcpy.da.SearchCursor("temp_terr_wireless_mau","MAU") as cursor:
    for row in cursor:
     wrt("MAU Value = " + "{0}".format(row[0]))
     wireMAU = ("{0}".format(row[0]))
     arcpy.Select_analysis("temp_terr_wireless_mau", "temp_mau_" + wireMAU, '"MAU" = ' +wireMAU)


    if arcpy.Exists("temp_mau_8"):
            arcpy.Erase_analysis("temp_terr_wireless_mau","temp_mau_8","temp_mau_e")
            arcpy.Merge_management(["temp_mau_e", "temp_mau_8"],"temp_terr_wireless_mau")
    if arcpy.Exists("temp_mau_7"):
            arcpy.Erase_analysis("temp_terr_wireless_mau","temp_mau_7","temp_mau_d")
            arcpy.Merge_management(["temp_mau_d", "temp_mau_7"],"temp_terr_wireless_mau")
    if arcpy.Exists("temp_mau_6"):
            arcpy.Erase_analysis("temp_terr_wireless_mau","temp_mau_6","temp_mau_c")
            arcpy.Merge_management(["temp_mau_c", "temp_mau_6"],"temp_terr_wireless_mau")
    if arcpy.Exists("temp_mau_5"):
        arcpy.Erase_analysis("temp_terr_wireless_mau","temp_mau_5","temp_mau_b")
        arcpy.Merge_management(["temp_mau_b", "temp_mau_5"],"temp_terr_wireless_mau")
    if arcpy.Exists("temp_mau_4"):
        arcpy.Erase_analysis("temp_terr_wireless_mau","temp_mau_4","temp_mau_a")
        arcpy.Merge_management(["temp_mau_a", "temp_mau_4"],"temp_terr_wireless_mau")

1 Answer 1

1

I'm not sure to understand everything in your code. But I can make the following suggestion:

i=8
arcpy.MakeFeatureLayer_management("mau","lyr_mau")
arcpy.SelectLayerByAttribute_management("lyr_mau","NEW_SELECTION", "value = " + str(i) )
arcpy.CopyFeatures_management("lyr_mau", "result_mau")
arcpy.SelectLayerByAttribute_management("lyr_mau","CLEAR_SELECTION")
arcpy.Erase_analysis("lyr_mau","result_mau","mau_"+i)
arcpy.MakeFeatureLayer_management("mau_"+i,"lyr_mau_"+i)

for i in range(7,2,-1):
    arcpy.SelectLayerByAttribute_management("lyr_mau_" + str(i+1),"NEW_SELECTION", "value = " + str(i) )
    arcpy.Append_management("lyr_mau_" + str(i+1),"result_mau","NO_TEST")
    arcpy.SelectLayerByAttribute_management("lyr_mau_" + str(i+1),"CLEAR_SELECTION")
    arcpy.Erase_analysis("lyr_mau_" + str(i+1),"result_mau","mau_"+i)
    arcpy.MakeFeatureLayer_management("mau_"+i,"lyr_mau_"+i)

"result_mau" is gone a hold your results. You will have to adjust the value field, because I was not sure of the name of the field from your code. Basically, the higher values present in the resulting layer erase the remaining features. It could be done with less layer or featureclass, but this way should works. Please note that I have not tested this, so it could have some errors(typos or ...).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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