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.
-
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?Hornbydd– Hornbydd2016年09月19日 13:33:14 +00:00Commented 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.Sil– Sil2016年09月19日 14:03:40 +00:00Commented Sep 19, 2016 at 14:03
-
1An 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.Hornbydd– Hornbydd2016年09月19日 14:10:36 +00:00Commented Sep 19, 2016 at 14:10
-
Would multiple polylineZ segments made of points pairs suffice?FelixIP– FelixIP2016年09月19日 20:19:22 +00:00Commented 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.Sil– Sil2016年09月20日 06:58:48 +00:00Commented Sep 20, 2016 at 6:58
1 Answer 1
I understand that you are Ok with 2 points segments simplification of original lines.
INPUT:
If you can get to this, using spatial join:
The script below will do the job:
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
-
Use add geometry attributes to derive elevations for ends of individual 3d linesFelixIP– FelixIP2016年09月20日 22:16:02 +00:00Commented 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)Sil– Sil2016年09月21日 09:08:30 +00:00Commented 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?Sil– Sil2016年09月21日 09:24:12 +00:00Commented Sep 21, 2016 at 9:24
-
It seems your points are sitting in database. Try on shape file.FelixIP– FelixIP2016年09月21日 09:24:18 +00:00Commented Sep 21, 2016 at 9:24
-
1See how it's done gis.stackexchange.com/questions/125090/…FelixIP– FelixIP2016年10月06日 19:38:26 +00:00Commented Oct 6, 2016 at 19:38