2

Using overpass-turbo I got data like this:

{
  "type": "way",
  "id": 292833530,
  "nodes": [
    2963934681,
    924717449,
    2963934682,
    2963934683,
    2963934684,
    2963934685,
    2963934686,
    2963934681
  ],
  "tags": {
    "addr:city": "Ivry-sur-Seine",
    "addr:housenumber": "134",
    "addr:postcode": "94200",
    "addr:street": "Avenue Danielle Casanova",
    "amenity": "post_office",
    "atm": "yes",
    "building": "yes",
    "change_machine": "yes",
    "moneo:loading": "yes",
    "name": "Ivry principal",
    "operator": "La Poste",
    "phone": "3631",
    "ref:FR:LaPoste": "17313A",
    "source": "data.gouv.fr:LaPoste - 01/2013",
    "stamping_machine": "yes",
    "wheelchair": "yes"
  }
}

Is there a way to get approxmatly the center of this building? I use

http://api.openstreetmap.org/api/0.6/node/ + one of the node

to get coordinate for un point but I would like something more in the center of the building.

2 Answers 2

7

The following Overpass API Query will return the center of your building:

[out:json]; way(292833530); out center meta;

1
0

I have found the solution on this stackoverflow topic .So here how I did it.
i request every node of the building using this:

http://api.openstreetmap.org/api/0.6/node/ + one of the node

and then the formule:

latitude1 = the lowest latitude
latitude2 = the hightest latitude
longitude1 = the lowest longitude
longitude2 = the highest longitude


center.longitude = longitude1 + ((longitude2 - longitude1) / 2);
center.latitude = latitude1 + ((latitude2 - latitude1) / 2);

This is the only solution I've found at the moment. It's long if you have a lot of building so a lot of request to make to the api(for every node of every building).

1
  • 1
    The main API is not meant for this kind of mass requests for each individual building. Please use Overpass API instead for this purpose, otherwise your IP address might get blocked by api.openstreetmap.org very soon!
    – mmd
    May 21, 2015 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.