Converting Direction Of Travel OSM vectors from “system” to another?

I have a painful doubt according Direction of Travel (DOT) vectors in OSM data. I'm using ArcGIS10, and a OSM data shapefile.

I have a OSM road layer, that has many "Both ways" vectors and many "One way". I'll consider only One way for my study.

Its DOT was performed as it was created the vector in its origin: The DOT is set from the start point of the vector to its finishing point.

But, I want to change this system to mine, which is:

• Each vector has a Reference Node and a Non-Reference Node.
• The Reference Node is the southernmost node and if the latitudes of both end nodes are identical and their longitudes differ, the Reference Node is the westernmost node.

An example: So, if I have a One way vector, I'm going to add its DOT with a letter T if it goes to the Reference Node or with a letter "F" to the Non-Ref node. An example: Considering that OSM one way vectors are set in another "system", how can I have it into my system?

I'm going to suggest an alternative approach here that should get you what you want and still leave the data in a conventional format.

As I pointed out in my comments on your other question, if you change the actual one-way attribute you will cause problems using network analysis software and confuse others working with the data because you won't be following the one-way and To/From convention generally expected (line direction, not cardinal direction). As mentioned in my comment above, one solution would be to flip the line and modify the one-way attribute from a binary yes/no to a different system as discussed here and below. But if all you're after is an attribute that has the cardinal direction (or a binary choice based on a common direction) of the one-way direction of travel, there's another way.

First, create a new field OnewayCard or similar. This will hold your system's DoT value. This can be T or F (confusing in my opinion), or N and S per your other question above, or you can break it down further to N NE E S SE S SW W NW, or spell them out - it's up to you.

Next, rather than determining this value by comparing lat/lon of the nodes as you identify above and are trying to do in this question, let's just look at the cardinal direction of the line by considering its angle. I don't know the exact way to do this - I think there's a function you can call to get it, and I saw this other question that actually has some code that will compute it. The goal is to get the azimuth, or full-circle bearing, of the line (0 and 360 degrees being north, 90 degrees east, 180 south, 270 west, etc).

Now we'll use an if statement - for simplicity sake I will follow your two variable example from above and the other question, but you could add more cases. If azimuth is between 0 and 90 or 270 and 360 then OnewayCard will be N (or north, or F). If azimuth is between 90 and 270 then OnewayCard will be S (or south or T). Of course you'd add more cases if you wanted the quadrants and/or true directions.

This method should work since your data just has yes/no for one-way and therefore the only possible direction of travel on a one-way is with the line. If your one-way variable allowed for other settings, such as the (0, 1, -1) system I mentioned here or just (To, From), you would need to add another level of if statement that would compare the line direction to the one-way restriction before assigning DoT. For example, a SW direction line with a -1 (against, or From) one-way value would actually have a NW DoT.

I tried the angle system of ChrisW, and it works!

I computed the bearing for each line, coded each bearing as: NE - NW - SE - SW in another field. Then flipped it, if there was a -1 on its "one way" attribute field, and voilà, there you have!!.

Here is an example: All I need now is to know how to compare automatically. I have thought about it, but I'm not getting any ideas. I have proposed in another question: Here the link

This comparison is not as simple as I thought.