I have a shapefile with a number of roughly parallel lines in it, and I want to calculate the spacing between these lines using a number of transects across the map.

How should I go about this? I have a bit of experience writing ArcPy scripts, so would be happy to write some code to do this, I just can't quite work out where to start. My best guess would be to draw the transect as a line, somehow create points where the transect line intersects with any other lines, and then calculate the average distance between the points. Does this seem like a sensible approach? If not, what would you suggest?

I need to be able to do this scriptably (from a Python script using ArcPy), which means I won't have access to functions that are only available from toolbar buttons.

  • Are you doing this because you need the spacings along the transects or because you need to estimate an average spacing between each adjacent pair of lines? (Or maybe some other reason?)
    – whuber
    Jan 27, 2011 at 22:58
  • Both I think! In the end I want to end up with an estimate of the average spacing between the lines, but I need to do it using transects placed regularly across the map so that I can compare it to other published results.
    – robintw
    Jan 28, 2011 at 13:14
  • I just updated the question to say that I need to be able to script this, which makes it a bit harder...
    – robintw
    Jan 28, 2011 at 18:32

2 Answers 2


I can think of a couple ways, but the simplest way that's coming to mind is if your transecting line is in the same feature class as your parallel lines, you can use the planarize function to break all the the lines at every intersection (be warned - do this in a copy of your feature class, because it will alter all geometry). Unfortunately, I don't have Arc 10 yet, but in 9.3 this is a button on the topology toolbar. After the lines are planarized, simply select all the segments of the transecting line, and run statistic on the shape length column to get min/max/avg distances. This approach would also work for multiple transecting lines at the same time, too.

  • That sounds perfect, apart from the fact that I can't seem to find a way to script the Planarize operation. It seems to only be available as a toolbar button, and not through a Python script. My aim would be to script these operations.
    – robintw
    Jan 28, 2011 at 13:13

Assuming arcpy can access these arcobjects interfaces, I'd try using ITopologicalOperator.Intersect, passing esriGeometry0Dimension. This should return a geometrybag of points. You can then sort these points based on their distance along the transect, which may be obtained using ICurve.QueryPointAndDistance.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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