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

OverpassAPI: different json formats

2
1

Hi,

I use the OverpassAPI to extract some data. Exporting them via the webinterface as geoJSON works fine but when I use an OverpassQL-link (example below) I receive a JSON-file with a different structure. How can I get a geoJSON-file with this link?

http://overpass-api.de/api/interpreter?data=[out:json];node(51.69,10.48,51.73,10.56)["highway"="street_lamp"];out;;

regards

asked 09 Jul '13, 12:34

Ogmios's gravatar image

Ogmios
766202639
accept rate: 25%

How does the structure differ? Is it a valid GeoJSON file? Did you remove the duplicated semicolon at the end of your link?

(09 Jul '13, 13:02) scai ♦

2 Answers:

6

Overpass returns a JSON format that is a direct representation of OSM data. This is not GeoJSON, because GeoJSON doesn't fit the OSM data structure.

In particular, in GeoJSON everything has a geometry, and topological incidence (like two ways sharing a node) is not represented directly. Also, GeoJSON differentiates between simple polygons and non-closed ways, which OSM does not (or again, not directly).

For these reasons, you need a conversion from OSM data to GeoJSON, and this is what Overpass Turbo does.

answered 13 Jul '13, 10:24

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

1

I have looked at the code that Overpass Turbo uses, in the hope that I could adapt the OSM4Leaflet.js code to easily add standard overpass JSON queries to my map.

This is the sort of thing I'd ideally like to be able to do:

var jsonLayer = new L.OSM4Leaflet(json).addTo(map);

Unfortunately I can't understand the complexities of the code used by Overpass Turbo. Could anyone help me out? It would be very useful to have a simple method be generally known.

answered 06 Aug '13, 15:41

Tom%20Chance's gravatar image

Tom Chance
16
accept rate: 0%

Source code available on GitHub .