New
This overpass request returns a bbox for each relation.

How to get a unique merged bbox ?

```
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“landuse=depot in Moselle”
*/
[out:json][timeout:25];
// fetch area “Moselle” to search in
{{geocodeArea:Marseille}}->.searchArea;
// gather results
relation["route"="subway"](area.searchArea);
// print results
out bb;
```
Aug 14, 10:06am

To get a unique merged bounding box (bbox) from multiple relations returned by your Overpass QL query, you need to:

  1. Extract the bbox of each relation from the response.
  2. Merge all bboxes into a single bbox that encompasses all individual bboxes.

How to do it:

1. Extract bboxes from the Overpass response

The Overpass API returns each relation with a bounds field if you use out bb;. The bounds field contains the min/max latitude and longitude for that relation.

Example of a relation with a bbox:

json

2. Merge all bboxes

To merge all bboxes into one, you need to find the minimum and maximum latitude and longitude across all relations.

  • minlat: The smallest minlat among all relations.
  • minlon: The smallest minlon among all relations.
  • maxlat: The largest maxlat among all relations.
  • maxlon: The largest maxlon among all relations.

Example in Python

If you want to do this programmatically (e.g., in Python):

python

Output

The output will be a tuple like: (48.8556, 2.3512, 48.8616, 2.3592)

This is your merged bbox.


Alternative: Use Overpass QL to get the union of all bboxes

If you want to do this directly in Overpass QL, you can use the union statement and then request the bbox of the union:

ql

This will return a single bbox for the union of all relations and their members.


Summary:

  • Extract all bboxes from the response.
  • Merge them by finding the min/max lat/lon.
  • Or use Overpass QL to get the union bbox directly.
Aug 14, 10:06am

This Chat is read-only. Login to resume chatting.

Sign in