This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

BBOX of a relation by its ID, API to obtan it

0
1

I have the ID of the relation, and I need a API that returns its boundary box.

Example: the relation 298204, openstreetmap.org/relation/298204... Where its boundary box?

PS: I need BBOX in standard format (ex. to use in Overpass).

asked 30 Jul '18, 16:48

ppKrauss's gravatar image

ppKrauss
95192225
accept rate: 0%

edited 30 Jul '18, 18:34

1

If you know the relation ID, you can use this straight in Overpass. Are you trying to find all places within (in this case) São Paulo

(30 Jul '18, 17:16) andrewblack

Hi @andrewblack, thanks. Well, the question was oriented to BBOX but will be welcome an extra "how to use relation ID with overpass" (instead BBOX, as spatial mask to the query).

(30 Jul '18, 18:38) ppKrauss

One Answer:

2

Finding the bounding box

relation   (298204) ;
out  bb ;

gives the information you want (but not quite in the right format. A bit if editing will get it.

bounds minlat="-25.4832679" minlon="-53.1090000" maxlat="-19.7823272" maxlon="-44.1610000"

Using a relation within Overpass

Assuming you want to do the query mentioned in Best way to retrieve a CSV table from Overpass , the following query uses the area defined by the relation, rather than a bounding box.

[out:csv(::id,::user,::type,wikidata,name,place, boundary)] ;
relation   (298204) -> .c ;
.c map_to_area -> .myarea ;
( 
  node (area.myarea)  [place] [wikidata] ;
  relation  (area.myarea) [boundary] [wikidata];  
);
out meta ;

In a bit more detail

  • Load the relation into set c
  • Create an area from set c.
  • run the query - (area.myarea) restricts it to this area

answered 30 Jul '18, 23:47

andrewblack's gravatar image

andrewblack
3651214
accept rate: 57%

Source code available on GitHub .