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 ArcMap.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityYou 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.
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);
}
}
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