TransWikia.com

Creating parallel lines in Geographic Coordinate System using ArcPy?

Geographic Information Systems Asked by sdMarth on March 26, 2021

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'..SCRARCHclone.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=-dY*sLength/lenV;sY=dX*sLength/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?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP