6

I have some lines. I want to draw perpendicular lines at the start and end of the lines, on both sides of the lines.

Can somebody help me in Python?

I am using ArcGIS.

5

You can try Feature Vertices To Points tool to extract start and end points of a polyline then apply this tool Station Lines Arc10.0, to generate perpendicular line along these points.

enter image description here

1

I have done something like this with arcObjects.

void DrawNormalOnPolyline(IPolyline polyline)
{
    IActiveView activeView = ArcMap.Document.ActiveView;
    double length = polyline.Length;
    ILine normalLine;
    normalLine = GetNormalOnPolylineFromStartPointToSpecificDistance(polyline, 0);//perpendicular line at start
    DrawLine(normalLine);
    normalLine = GetNormalOnPolylineFromStartPointToSpecificDistance(polyline, length);//perpendicular line at end
    DrawLine(normalLine);
    activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}

ILine GetNormalOnPolylineFromStartPointToSpecificDistance(IPolyline polyline, double distance)
{
    double normalLineLength = 0.01;
    ILine normal = new Line();
    ICurve curve = polyline;
    curve.QueryNormal(esriSegmentExtension.esriNoExtension, distance, false, normalLineLength, normal);
    return normal;
}

void DrawLine (ILine normalLine)
{
    IElement element = null;
    IGraphicsContainer graphicsContainer = (IGraphicsContainer)ArcMap.Document.FocusMap;

    ILineElement lineElement = new LineElementClass();
    lineElement.Symbol = GetLineStyle();
    element = (IElement)lineElement; 

    if (!(element == null))
    {
        element.Geometry = GetLineGeometry(normalLine);
        graphicsContainer.AddElement(element, 0);
    }
}
0

Here is a Python toolbox to create an assortment of perpendicular lines at various places along the line including starts and end points... ftp://lnnr.lummi-nsn.gov/GIS_Scripts/createperpendicularlines.zip

  • Also see Perpendicular Transects ArcGIS 10 toolbox by Mateus Ferreira. It's also for creating perpendicular at regular intervals along the line instead of just at ends, but has an option for deriving the split distance from a field name. Perhaps if the Length field was used it would only do end points. – matt wilkie Jun 16 '15 at 19:08
  • GBG we generally discourage link-only answers. Inevitably they succumb to link-rot and then the "answer" doesn't apply any more. If you can, include something that will allow a future searcher to (re)build their own solution when the destination link has disappeared. – matt wilkie Jun 16 '15 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.