A
A
Anton Shelestov2018-03-31 09:20:44
OpenStreetMap
Anton Shelestov, 2018-03-31 09:20:44

How to convert data from Openstreetmap to geoJSON?

Hello people.
I want to get the districts of Russia in the form of polygons
, there is a site overpass-turbo.eu/s/xu9 through such a request everything turns out, polygons are displayed. But the data is not returned in polygon format.
There, on that site, there is an "Export" section in the menu and a link "download to geoJSON" by clicking on it, a file with polygons is loaded, etc. exactly what is needed.
Question: how to get such unloading via api now?
Because a query like this:

$client = new Client();

        $res = $client->request('GET', 'http://overpass-api.de/api/interpreter', [
            'query' => [
                'data' => '[out:json];
                    relation
                        ["addr:country"="RU"]
                        //["coverage"="polygon"]
                        ["admin_level"=3];  
                    out geom;
                ',
            ],
            'headers' => [
                'Content-Type' => ' application/json'
            ]
        ]);
        $objects = json_decode($res->getBody()->getContents());

returns unformatted data.
joxi.ru/MAjoJovF4V0wKr

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2018-03-31
@shurshur

Overpass does not support geojson export, see https://github.com/drolbr/Overpass-API/issues/48 Use https://github.com/tyrasd/osmtogeojson/
instead

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question