Skip to content

Instantly share code, notes, and snippets.

@amarinelli
Created September 25, 2014 18:32
Show Gist options
  • Save amarinelli/29fe10a8c7ab3da3208d to your computer and use it in GitHub Desktop.
Save amarinelli/29fe10a8c7ab3da3208d to your computer and use it in GitHub Desktop.
Assign address ranges from point layer to road reference data
import arcpy
streets = []
#
#Search cursor code here to get list of streets
#
arcpy.MakeFeatureLayer_management("<file path>","roads_lyr")
arcpy.MakeFeatureLayer_management("<file path>","points_lyr")
for street in streets:
arcpy.SelectLayerByAttribute_management("roads_lyr", "NEW_SELECTION", "STREET_NAM = " + street)
arcpy.SelectLayerByAttribute_management("points_lyr", "NEW_SELECTION", "STREET_NAM LIKE '{0}%'".format(street))
# This tool modifies input data and does not create new data
arcpy.Snap_edit("points_lyr", [["roads_lyr", "EDGE", "50 Meters"]])
#
#Code here to do something with newly snapped features and current selections
#ex. Select By Location (intersects)
#Find address ranges and assign them to roads layer
#
print "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment