Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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? Also, what are the variable settings of the script?

share|improve this question
2  
What software.? –  Nathan W Jan 22 '13 at 12:20
    
Python, ArcGis, –  Marjo van Balen Jan 22 '13 at 12:27

1 Answer 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);
    }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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