2

Goal: Move address points to their correct location.

Plan: I have a layer of AddressPoints of which some need moved to a new location. I want to take a line layer (called AddressPoints_AdjustLocation, shown as a purple dashed line below) and draw a line from the address points current location (which is usually close to the road) to the desired location (which is the front door of the building)

Adjust AddressPoints Location

Code I have so far:

    arcpy.MakeFeatureLayer_management("../pathToAddressPoints", "lyr_AddressPoints")
    arcpy.MakeFeatureLayer_management("../pathToAddressPoints_AdjustLocation", "lyr_AddressPoints_AdjustLocation")

    # Create a cursor that holds all the selected AdjustLocation features
    rows = arcpy.SearchCursor("lyr_AddressPoints_AdjustLocation")
    if rows:
        for row in rows:
            feat = row.getValue("SHAPE")
            vertex_list = []
            for vertex in feat.getPart(0):
                if vertex:
                    vertex_list.append([vertex.X, vertex.Y])

            vertexStart = vertex_list[0]
            # TODO: Select all address points in "lyr_AddressPoints" that intersect the vertexStart location


            vertexEnd = vertex_list[-1]
            # TODO: For each address point selected above, move it to the vertexEnd location

The two items I need help with are how to select address points that Intersect the vertexStart position, and then moving those address points to the vertexEnd location (using UpdateCursor I assume).

3
  • What version of ArcMap do you have access to?
    – Paul
    Commented Dec 12, 2015 at 20:43
  • Sorry, ArcGIS for Desktop Advanced 10.3.1... also just installed ArcGIS Pro, but haven't gotten into that yet... Commented Dec 12, 2015 at 20:54
  • Do the green dots always fall within the same parcel as they desired destination? Are there point features for the desired end locations? Commented Dec 13, 2015 at 5:46

2 Answers 2

1

So I ended up solving my problem by using a little bit of a different method... So what I do is draw a line from where the address point is that I want to move, and end the line at where I want the address point to end up at. When I run my code, it goes through and selects each line one at a time, then selects all the address points that intersect that line (anywhere along that line, not just at the beginning which what I was trying to do before...), and moves all the address points (usually just one) to the last vertex of the line. Doing it this way would allow me to select multiple address points with the same line if needed, and move them all to the same spot.

The reason I have this in a script is because I download the original address points from a county website (repeatedly every couple of weeks), and then combine them with my additions/corrections/deletions, then merge them with other counties to make one big dataset. So this way I can move the address points to where I want them without bothering the original datakeepers.

arcpy.MakeFeatureLayer_management("../pathToAddressPoints", "lyr_AddressPoints")
arcpy.MakeFeatureLayer_management("../pathToAddressPoints_AdjustLocation", "lyr_AddressPoints_AdjustLocation")

# Create a cursor that holds all the selected AdjustLocation features
rows = arcpy.SearchCursor("lyr_AddressPoints_AdjustLocation")
if rows:
    for row in rows:
        arcpy.SelectLayerByAttribute_management("lyr_AddressPoints_AdjustLocation", "NEW_SELECTION", "\"OBJECTID\" = " + str(row.getValue("OBJECTID")))
        arcpy.SelectLayerByLocation_management("lyr_AddressPoints", "INTERSECT", "lyr_AddressPoints_AdjustLocation")
        print("WARNING!!!: LOCATION ADJUST OBJECTID " + str(row.getValue("OBJECTID")) + " DID NOT SELECT ANY ADDRESS POINTS!!!" if arcpy.GetCount_management("lyr_AddressPoints").getOutput(0) == '0' else "OBJECTID " + str(row.getValue("OBJECTID")) + " selected " + arcpy.GetCount_management("lyr_AddressPoints").getOutput(0) + " feature(s) for location adj")

        if arcpy.GetCount_management("lyr_AddressPoints").getOutput(0) <> '0':
            # Get the x,y of the vertexes of the current AdjustLocation feature
            feat = row.getValue("SHAPE")
            vertex_list = []
            for vertex in feat.getPart(0):
                if vertex:
                    vertex_list.append([vertex.X, vertex.Y])

            pntLastVertex = arcpy.Point(vertex_list[-1][0], vertex_list[-1][1])         # Convert the last vertex into a Point
            aprows = arcpy.UpdateCursor("lyr_AddressPoints")
            for aprow in aprows:
                aprow.setValue("SHAPE", pntLastVertex)
                aprows.updateRow(aprow)
0

Provided that address points will always refer to the closest building (which may not always the case I guess), you could use the Near GP tool to find out the closest feature in the buildings layer (or you could create buildings centroid points first).

You could then use the arcpy.da.UpdateCursor to update the geometry of the source address points based on what feature they have closest. The XY coordinates of the closest building centroid will be calculated in two added fields - NEAR_X and NEAR_Y.

If you want to move your address points to the front door location, you would need to have doors stored either as points (which is use with the Near tool) or you can be happy about having the building centroid (if this is sufficient for your purposes and you don't want to digitize the door location manually).

Your Answer

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

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