[GIS] How to preserve original direction of NHD segments when creating route using gp.CreateRoutes_lr tool

arcgis-9.3arcgis-desktoplinear-referencing

I am trying to figure out how to preserve the original line direction of NHD High Resolution data that I am selecting out and creating a route with. I'm using ArcGIS 9.3.1 and this is a python script.

I am selecting out some of the NHD streams by the ReachCode field into a new feature class (I have also tried this with a feature layer in the context of the issue I'm posting about but creating a separate feature class allowed me to debug further), and then am taking that feature class and dissolving it. I then take that dissolved NHD section and am creating a route with the gp.CreateRoutes_lr tool.

I've narrowed down the issue to the step when the script creates the route and it seems that the direction of the line feature gets flipped when I create the route (I have definitively verified this is happening). Is this what is supposed to happen? I've never worked with the linear referencing tools before this so am unsure if this is what should be happening.

Each of the line segments have a defined FROM and TO node direction which is important for streams in terms of correct flow direction. The reason the direction matters to me for my script is that I am creating the vertices via the gp.FeatureVerticesToPoints_management tool get the elevations of the FROM and TO node to determine the stream slope for points located along the NHD section. This impacts the slope calculation obviously.

I just compared a site that had a negative slope (with assumption that a negative slope implies an instance where the route direction got flipped as I describe) with a site that had a positive slope (with assumption that a positive slope indicates an instance where the route direction did not get flipped). Both assumptions were true, and it seems for the former the direction got flipped, and the latter it did not. So it seems that this tool does not flip the directions consistently…

Is there any way to preserve the original direction of the NHD segments when I create a route? Or, what would influence the direction of the output route line feature?

Best Answer

So after trying every possible scenario I could imagine, I finally stumbled on why the Create Routes tool was arbitrarily flipping the direction of the NHD stream segments. In the tools's online information, you can choose to either use the geometric length to obtain the routes, or custom fields you have created as one field or two field for the input of specifying how routes will be obtained. The default is the "Length" option and I had actually used that default for another script that was calculating a per-NHD-segment feature class, and it worked fine in that script. But, because I was using multiple NHD segments to create the route, such a scenario is when apparently you need to use the two field option.

So I added a "FromM" field for the "from measurement", and a "ToM" field for the "to measurement" to the dissolved NHD segments before creating my route. I calculated the "FromM" value to zero, and the "ToM" value to "!Shape_Length!". I then modified the CreateRoutes input accordingly, and the script worked fine.

This is exactly why "default" selections for software tools like this is really dangerous. I know I should be more diligent in researching all options for each input of a tool and for the most part I am. But even in this case had I done that, and I had poured over the online help and searched online high and low, not sure I would have been enlightened. This is not the first time ESRI default values have tripped me up. But, it's a double problem when the information on the tool really doesn't elucidate the implications of the options for a particular input when a default is specified (at least as far as I can tell with tis particular instance). Either way, note that during my testing and debugging that the tool was not consistently flipping the direction for every dissolved set of segments, only certain ones (and not sure what drives that) which made it even more tricky to figure out what the issue was. Anyhow...onward and upward

Related Question