Hi, I would like to resolve a list of negative OSMids/relations to a coordinate. For example, Paris with a relation of "-71525" would like to get a pair of coordinates back. I already tried using the Overpassturbo API, but there I only get a list of nodes and other entities, not the coordinates. Does anybody know how to do it? Thanks! asked 17 Sep '21, 12:09 Garome |
Given your clarification not using a negative id, you could simply do like this:
Which will give you the coordinates of the centre:
The relation is shown on https://www.openstreetmap.org/relation/71525 and its centre is marked on https://www.openstreetmap.org/?mlat=48.8588657&mlon=2.3469411. (Observe that the centre of an area might also be outside the area depending on the area's shape.) answered 12 Jan '22, 16:27 Gåseborg Thanks a lot for your answer!
(25 Jan '22, 21:32)
Garome
|
For those who want to do it even more simply. https://overpass-turbo.eu/s/1frI
answered 26 Jan '22, 00:19 DaveF |
Why do you have a negative id for the relation? The relation is a closed polygon. Do you want a single co-ordinate pair for the centroid or a pair for each node?
I used a list of nodes and relations with positive and negative values, where the positive values refer to nodes and the negative values refer to relations. The positive values/nodes I already converted into a coordinate, but for the negative ones/relations I have no idea how to do it. I would like to get a single coordinate for each relation back (for the centroid). Thanks for your reply!
I think the "negative" before the value is only for separating nodes and relations. So I for Paris the relation is "71525" and not "-71525".
For completeness, I believe that the negative id just means that it's a value from a database loaded by osm2pgsql from a relation. osm2pgsql will add way 12345 as "12345" and relation 12345 as "-12345" to the _line or _polygon tables. Just remove the "-" to get the OSM relation number.
Oh for crying out loud, not once did Garome mention osm2pgsql.