0

I have a point which is some meters away from an existing line:

enter image description here

This point should be snapped to the line (to the closest part) and then, based on the points' new coordinates, a new line Feature Class should be created, which is on the existing line 1,5 meters left and 1,5 meters right (so 3 meters total) of the point. Therefore it should look like the following picture:

enter image description here

Existing Datasets shouldn't be used, the result should be in a new FC.

Here is the code is used so far:

 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])

The hardest part for me is to find out how to get the 1,5m on both sides...which tools could be used to do that or is there an alternative way?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Feb 8, 2016 at 14:22

1 Answer 1

1

There are two answers depending on your definition of distance: bird's flight or along the road. they wil be identical on a straight line but differ on curves or broken lines.

bird's flight

you could create a buffer around your point, then intersect the buffer geometry with the line. You can do this for all your points at once using the geoprocessing tool on the feature class or work on the geometry objects within a cursor.

with arcpy.da.SearchCursor(point_feature, ['SHAPE@']) as cursor:
 for row in cursor:
 buffer = arcpy.Buffer_analysis(row[0], arcpy.Geometry(), "1.5 meters")[0]
 line_feature = arcpy.Clip_analysis(input_lines, buffer, arcpy.Geometry())[0]
#do what you want with the resulting geometry 

Distance along line

For distance along line you can use linear referencing tools. You'l first need to create measures on your lines, then you can locate the feature along the route and then create a route event by adding/removing 1.5m from your point measured value. The created layer can be stored as a geometry if needed. (with arcpy copy )

answered Feb 8, 2016 at 14:30
5
  • thank you. Isn't there an option to achieve that using geometry objects? Commented Feb 8, 2016 at 14:45
  • you can use buffer and intersect on the geometry objects Commented Feb 8, 2016 at 15:05
  • see eg gis.stackexchange.com/questions/109451/… Commented Feb 8, 2016 at 15:06
  • or blogs.esri.com/esri/arcgis/2010/02/23/… Commented Feb 8, 2016 at 15:07
  • It can be achieved by using combination of measureOnLine positionAlongLine (10.2 or higher) on geometry services. Remember buffer and linear referencing will produce the same (very close) results for straight line only Commented Feb 8, 2016 at 19:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.