2

I have two lines with xy values, but no z values. However, I have points with xyz values that intersect with the two lines (see attached image for vizualisation). How can I get the z values from the points to the lines?

I have tried spatial join (join one to many), but with around 400 points for each of the two lines this just results in feature classes with around 400 20km lines with different z values. I would like the lines to be split at each point and assigned a z value, but cannot use Split Line at Point as I only have the Basic licence. I use ArcGIS 10.3.1.

enter image description here

ahmadhanb
41.8k5 gold badges55 silver badges109 bronze badges
asked Sep 19, 2016 at 11:35
8
  • Are the original lines composed of only 2 vertices, the start and end vertex or are composed of more? I ask this as what value do you want the vertices that make up the original line (which may not coincide with your point dataset) to be? Commented Sep 19, 2016 at 13:33
  • Yes, the original lines have start and end vertices in xy values, each line has only one row in its attribute table. So my wish is to have the lines divided based on each point, giving it new start and end vertices in xy values, together with a z value. Commented Sep 19, 2016 at 14:03
  • 1
    An approach to overcome the lack of license issue is to use linear referencing to create the line segments, have a look at the help file. Commented Sep 19, 2016 at 14:10
  • Would multiple polylineZ segments made of points pairs suffice? Commented Sep 19, 2016 at 20:19
  • Hornbydd: which of the linear referencing tools do you suggest? I have looked into them all and I cannot seem to get them to create anything with any values. I will continue looking into this though. FelixP: How do I go about transforming the lines to polylineZ segments? Thanks to both of you. Commented Sep 20, 2016 at 6:58

1 Answer 1

1

I understand that you are Ok with 2 points segments simplification of original lines.

INPUT:

Example data

If you can get to this, using spatial join:

Tables

The script below will do the job:

Script output

Script assumes that layer called "lines3d" is empty PolylineZ layer:

import arcpy
## input parameters
mxd = arcpy.mapping.MapDocument("CURRENT")
lines2d = arcpy.mapping.ListLayers(mxd,"LINES")[0]
points = arcpy.mapping.ListLayers(mxd,"POINTS")[0]
lines3d = arcpy.mapping.ListLayers(mxd,"lines3D")[0]
d=arcpy.Describe(lines2d)
SR=d.spatialReference
curT=arcpy.da.InsertCursor(lines3d,"Shape@")
## get a list of lines
lineDict={}
with arcpy.da.SearchCursor(lines2d,("Shape@","LineId")) as cursor:
 for shp, lineid in cursor:
 lineDict[lineid]=shp
## shuffle through lines
for entry in lineDict:
 line=lineDict[entry]
 q='"LineId"=%s' %"'"+entry+"'"
 listOfPoints=[]
 with arcpy.da.SearchCursor(points,("Shape@","Z"),q) as cursor:
 for pnt,z in cursor:
 p=pnt.firstPoint
 p.Z=z
 listOfPoints.append([line.measureOnLine(p),p])
##create 2 points segments
 modList=sorted(listOfPoints)
 for i,row in enumerate(modList):
 if i==0:p1=row[1];continue
 p2=row[1]
 pLine=arcpy.Polyline(arcpy.Array([p1,p2]),SR,True)
 p1=p2
 curT.insertRow((pLine,))
del curT

You can overcome a lot of license restrictions if you know Python

Hornbydd
44.9k5 gold badges42 silver badges84 bronze badges
answered Sep 20, 2016 at 22:08
10
  • Use add geometry attributes to derive elevations for ends of individual 3d lines Commented Sep 20, 2016 at 22:16
  • Thank you! I do however get this error message: Runtime error Traceback (most recent call last): File "<string>", line 22, in <module> RuntimeError: An invalid SQL statement was used. [inbound_elevationpoints] Line 22 is: for pnt,z in cursor: (and "inbound_elevationpoints" is the name of my points) Commented Sep 21, 2016 at 9:08
  • A question about the spatial join mentioned above, @Hornbydd, am I meant to use the spatially joined points in the script? Or the spatially joined lines? Commented Sep 21, 2016 at 9:24
  • It seems your points are sitting in database. Try on shape file. Commented Sep 21, 2016 at 9:24
  • 1
    See how it's done gis.stackexchange.com/questions/125090/… Commented Oct 6, 2016 at 19:38

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.