NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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?


asked 17 Sep '21, 12:09

Garome's gravatar image

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

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

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 '22, 18:31) SomeoneElse ♦

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

(26 Jan '22, 00:15) DaveF

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

(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 and its centre is marked on (Observe that the centre of an area might also be outside the area depending on the area's shape.)

permanent link

answered 12 Jan '22, 16:27

G%C3%A5seborg's gravatar image

accept rate: 50%

edited 12 Jan '22, 16:37

Thanks a lot for your answer!

(25 Jan '22, 21:32) Garome

For those who want to do it even more simply.

out center;
permanent link

answered 26 Jan '22, 00:19

DaveF's gravatar image

accept rate: 16%

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 17 Sep '21, 12:09

question was seen: 1,356 times

last updated: 26 Jan '22, 00:19

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum