1

I'm trying to figure out which ways are "the same". One metric I'd like to check is the angle between them: if two ways meet at a node at an angle pretty close to 180 degrees, that's an indication that they should be treated as the same for my purposes.

Specifically, I'd like to find the angle between ways that share a start/end node using the Overpass API.

So far, I've come up with this, which lets me find the adjacent nodes. From there, in principle I just need to do some trig, but that doesn't seem to be available. There's the angle() evaluator, but that only works on nodes internal to a way, and I don't think it's possible to construct a synthetic way from a given set of points.

I've considered constructing the trig myself. I could use the taylor series for arctan, in theory, or I could take dot products and work with cosines instead of the angles directly. Since I only want to check if the angle is within a certain range, in principle that should work. But it seems frankly hideous. Also, to do this accurately, I'd need to be able to project to something where the x and y units are approximately equal (that is to say, I can't just use lat and lon).

I've considered doing this in post-processing, but the issue is that I want to check this inside a complete block in Overpass. Doing this client-side would mean I need an arbitrary number of round-trips to the Overpass API.

1
  • Overpass API is not a general purpose GIS tool. For your use case, I would recommend to download some OSM extract, import it into a PostgreSQL DB with PostGIS, and do the number crunching there. You should probably only import the subset of data that's relevant here to keep disk storage requirements low.
    – mmd
    Commented May 31 at 21:55

1 Answer 1

0

It is indeed hideous, but you can approximate atan using something like this https://overpass-turbo.eu/s/1QRg (finds all pylons in Oxfordshire along a particular bearing).

I think making deriveds identical to the basic nwr types is crucial for Overpass to be usable in interesting cases like this.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 8 at 20:36

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.