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's gravatar image

Garome
15113
accept rate: 0%

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?

(17 Sep '21, 13:36) DaveF

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!

(17 Sep '21, 13:54) Garome
2

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".

(17 Sep '21, 14:20) Garome
2

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.

(25 Jan, 18:31) SomeoneElse ♦

Oh for crying out loud, not once did Garome mention osm2pgsql.

(26 Jan, 00:15) DaveF

Given your clarification not using a negative id, you could simply do like this:

[out:csv(::type,::id,name,::lat,::lon)][timeout:20];
(rel(71525);) -> .object;
.object out center;

Which will give you the coordinates of the centre:

@type       @id     name    @lat        @lon
relation    71525   Paris   48.8588657  2.3469411

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.)

permanent link

answered 12 Jan, 16:27

G%C3%A5seborg's gravatar image

Gåseborg
28161014
accept rate: 50%

edited 12 Jan, 16:37

Thanks a lot for your answer!

(25 Jan, 21:32) Garome

For those who want to do it even more simply.

https://overpass-turbo.eu/s/1frI

[out:csv(::type,::id,name,::lat,::lon)];
rel(71525);
out center;
permanent link

answered 26 Jan, 00:19

DaveF's gravatar image

DaveF
3.0k7793127
accept rate: 15%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×463
×230
×215
×141

question asked: 17 Sep '21, 12:09

question was seen: 652 times

last updated: 26 Jan, 00:19

powered by OSQA