[GIS] Calculating spacing of polylines along transects using ArcPy

arcgis-10.0arcpyvector

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.

Best Answer

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.