1

I have a polyline feature class that is using GCS_WGS_1984 (code 4326). I am trying to create lines that are parallel to a polyline from this feature class at distance d.

From some searching, I've only been able to find out how to create parallel lines here:

Creating parallel line in ArcGIS Pro using ArcPy?

but it only works for 2D:

import arcpy, math
infc=r'..\SCRARCH\clone.shp'

def CopyParallel(plyP,sLength): part=plyP.getPart(0) lArray=arcpy.Array();rArray=arcpy.Array() for ptX in part: dL=plyP.measureOnLine(ptX) ptX0=plyP.positionAlongLine (dL-0.01).firstPoint ptX1=plyP.positionAlongLine (dL+0.01).firstPoint dX=float(ptX1.X)-float(ptX0.X) dY=float(ptX1.Y)-float(ptX0.Y) lenV=math.hypot(dX,dY) sX=-dYsLength/lenV;sY=dXsLength/lenV leftP=arcpy.Point(ptX.X+sX,ptX.Y+sY) lArray.add(leftP) rightP=arcpy.Point(ptX.X-sX, ptX.Y-sY) rArray.add(rightP) array = arcpy.Array([lArray, rArray]) section=arcpy.Polyline(array) return section

with arcpy.da.UpdateCursor(infc,("Shape@","Width")) as cursor: for shp,w in cursor: twoLines=CopyParallel(shp,w) cursor.updateRow((twoLines,w))

I have tried first projecting to spatial reference code 3857, then running the above code, then converting back. However, there is some distortion (~8% error).

Is there a solution that would work for geographic coordinate systems?

sdMarth
  • 141
  • 1
  • 3
  • -1 for not mentioning the source. – FelixIP Nov 25 '20 at 02:36
  • I've added the source – sdMarth Nov 25 '20 at 02:39
  • 2
    Spatial references with projected and geographic coordinate systems should behave very differently. Doing Cartesian math on a geographic CS does not work, and no distance measurement should ever be trusted in Web Mercator. ArcPy provides the tools to perform the Forward and Inverse geodetic problems (PointGeometry methods pointFromAngleAndDistance () and angleAndDistanceTo(), respectively), or you can project to an appropriate projection, then project back). Note that the parallel lines will not look parallel in a GCS (and you may need to densify the line first). – Vince Nov 25 '20 at 03:20
  • 1
    Ok. I removed my downvote. – FelixIP Nov 25 '20 at 04:03
  • hi @Vince, can you elaborate on why there may be a need to densify? – sdMarth Nov 25 '20 at 17:13
  • @sdMarth A 'line' that is straight in one CRS may not be straight in another CRS. This affects longer lines more, of course, and is generally more true for east-west lines. – mkennedy Dec 02 '20 at 20:15

0 Answers0