# How to split a line into a set of equidistant points

Used to rely on XTools for this, but in my current environment, I don't have access to it.

I'm trying to do this in ArcMap10.

The goal is to break a line representation of a stream into a set of equally-spaced points in order to eventually determine z values at those points so that I can determine gradient.

My intended workflow is as such.

1. split the stream into points
2. intersect the points with a DEM using GME
3. By determining the distance between the points, I should be able to determine that the gradient is.
4. Seems like it would make sense to integrate the point data back into the original streamlines. Unsure about this step.

I appreciate any critiques of my method, but my priority at this point is converting those streams to points.

Thank you!

• Do you want the distance to be with respect to measure (m) or simple based on planimetric x/y distance? – Kirk Kuykendall Apr 25 '11 at 12:51
• With respect to a measure Kirk. – Jacques Tardie Apr 25 '11 at 15:07

## 3 Answers

I'm not using ArcGIS 10 yet, but in 9.3.1 you can start an edit session on your line layer, highlight the feature you want to divide then on the Editor Toolbar drop down select the Divide option. Here you can specify the distance to divide the selected feature by. You can then use the Export Nodes tool within ET GeoWizard (free tool) to get a point layer for each divided line segment.

You can use a spatial join to put the point data info back into the line layer. Right click your line layer in ArcMap TOC and select Join and Relates>Join. On the first drop down select "Join data from another layer based on spatial location" option.

• Thanks artwork, I'll give this a try later today. Sounds very reasonable to me! Thank you :) – Jacques Tardie Apr 25 '11 at 15:08

I'm not aware of a tool on the UI that does this, but it can be done programmatically, via the IMSegmentation3 interface.

``````protected override void OnClick()
{
try
{
var fSel = ArcMap.Document.FocusMap.get_Layer(1) as IFeatureSelection;
if (fSel.SelectionSet.Count == 0)
{
MessageBox.Show("choose a line feature first");
return;
}
var gc = ArcMap.Document.FocusMap as IGraphicsContainer;
IFeature feat = ((IFeatureLayer)fSel).FeatureClass.GetFeature(fSel.SelectionSet.IDs.Next());
var pnts = GetPoints((IPolyline)feat.ShapeCopy, 2.0);
foreach (IPoint pnt in pnts)
{
var elem = new MarkerElementClass() as IElement;
elem.Geometry = pnt;
((IMarkerElement)elem).Symbol = new SimpleMarkerSymbolClass();
gc.AddElement(elem, 0);
}
((IActiveView)ArcMap.Document.FocusMap).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

/// <summary>
/// Get points at evenly spaced measures along a polyline
/// </summary>
/// <param name="polyline"></param>
/// <param name="count"></param>
/// <returns></returns>
private List<IPoint> GetPoints(IPolyline polyline, double mspacing)
{
var outList = new List<IPoint>();

var mseg = polyline as IMSegmentation3;
if (mseg.MMonotonic == esriMMonotonicEnum.esriMNotMonotonic)
throw new Exception("polyline not monotonic");
for (double m = mseg.MMin; m <= mseg.MMax; m += mspacing)
{
var geomcoll = mseg.GetPointsAtM(m, 0.0);
if (geomcoll != null && geomcoll.GeometryCount > 0)
{
var pnt = geomcoll.get_Geometry(0) as IPoint;
outList.Add(pnt);
}
}
return outList;
}
``````

You could make a buffer at one end of the stream and then identify the point where your buffer intersects the stream. Then you could just keep repeating this step. It would not give you the exact distance of the stream (as it is straight line, rather than stream length), but if you could then split the line into sections based on these points, and using the length of those lines estimate the gradient.

This could be scripted in python if it was a worthy approach!