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

Efficient approach to get center coordinate for ways via overpass

1

I'm using overpy library to query overpass via python.

I'd like to have a list of entities with a certain tags and their coordinates. For nodes this is straightforward. For closed ways (polygons) I'd just need the centroid lat/lon.

Often those aren't stored in center_lat,center_lon, so I'm launching queries against the list of nodes associated to that ways entity.

This query, using get_nodes, leads to a lot of HTTP errors (apparently overpy requires to launch queries again to get this). So, I'm wondering if there's a more efficient route to get what I need (and in the mean time don't bother the servers so much).

asked 10 Oct '17, 16:53

WouterDX's gravatar image

WouterDX
26113
accept rate: 0%


One Answer:

3

use "out center" as e.g. in this query which gives the center nodes of buildings.

answered 11 Oct '17, 04:07

escada's gravatar image

escada
19.0k16166302
accept rate: 21%

Perfect, thanks.

(11 Oct '17, 09:03) WouterDX