0

I would like to perform a request to OSM Overpass Turbo API or Overpass API from and Android Application so i can get the buildings around and area using JSON.

Something similar to http://overpass-turbo.eu/ with the query presented below:

[out:json][timeout:25];
// gather results
(
  // query part for: “building”
  way["building"](37.98350674557998,23.72600823640823,37.98552989685638,23.728837966918945);
  relation["building"](37.98350674557998,23.72600823640823,37.98552989685638,23.728837966918945);
);
// print results
out body;
>;
out skel qt;

The thing is that i need the results in geojson like the result below but i cannot find any query that gives me the below result.

{
  "type": "FeatureCollection",
  "generator": "overpass-turbo",
  "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.",
  "timestamp": "2015-03-23T20:41:02Z",
  "features": [
    {
      "type": "Feature",
      "id": "relation/2604192",
      "properties": {
        "@id": "relation/2604192",
        "building": "yes",
        "type": "multipolygon"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              23.7319885,
              37.9752441
            ],
            [
              23.7319787,
              37.9751612
            ],
            [
              23.7319494,
              37.9751641
            ],
            [
              23.7319372,
              37.9748376
            ],
            [
              23.7319702,
              37.9748318
            ],
          ]
        ]
      }
    },

I get only results with nodes but not with geometry.

{
  "type": "way",
  "id": 25107859,
  "nodes": [
    2373953582,
    2373953586,
    2373953592,
    2373953599,
    2373953597,
    2373953636,
    2373953633,
    2373953626,
    273319309,
    2373953582
  ],
  "tags": {
    "building": "yes"
  }
},

After some useful comments (thanks scai) i found out that overpass turbo is not queried automatically. Therefore i searched for overpass api and i found out this site with a query for buildings to overpass api exporting to GeoJSON but i does not work (though the xml query in the site works but i need json). Anyone has a query that works so i can follow it?

http://inasafe.org/en/developer-docs/osm_building_downloads.html

http://overpass-api.de/api/interpreter?data=[out:json];(node[%23building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725);way[%22building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725);relation[%22building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725););(._;%3E;);out%20body;
user2713459
  • 49
  • 2
  • 5
  • Note that GeoJSON is only supported by overpass turbo which is not designed to be queried automatically. Overpass API instead only supports JSON. Your first query already returns JSON including geometry information, isn't this enough for you? – scai Mar 24 '15 at 08:00
  • One option to convert JSON to GeoJSON might be https://github.com/tyrasd/osmtogeojson - this library is also used in overpass turbo. – mmd Mar 24 '15 at 16:59

0 Answers0