Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy
- arcpy.env.workspace = arcpy.GetParameterAsText(0)
- point_feature = arcpy.GetParameterAsText(1)
- line_feature = arcpy.GetParameterAsText(2)
- # Make backup copy of point feature class, since modification with
- # the Editing tools below is permanent
- arcpy.CopyFeatures_management(point_feature, "point_feature_backup")
- # Snapping-Tool
- arcpy.Snap_edit(point_feature,[[line_feature,"EDGE","50 METERS"]])
- # Getting the coordinates of the new snapped Point
- with arcpy.da.SearchCursor(point_feature, ['SHAPE@XY']) as cursor:
- print ("Coordinates of the snapped point: {}".format(row[0]))
- # Creating the new line, I used phantasy coordinates here, it was just a test, the new Coordinates should be on the already existing line 1,5m left and 1,5m right of the snapped point
- cursor = arcpy.da.InsertCursor(line_feature, ["SHAPE@"])
- array = arcpy.Array([arcpy.Point(1823123.213, 6139654.819),
- arcpy.Point(1823123.244, 6139654.869)])
- polyline = arcpy.Polyline(array)
- cursor.insertRow([polyline])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement