NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I'm trying to get the center point with Python and overpy:

api = overpy.Overpass()
result = api.query("""way(381501602);out center;""")

but unlike to Overpass Turbo, where I get the center point 49.2559306 / 8.4525152 overpy just returns all nodes:

result.nodes is empty and result.ways contains

< overpy.Way id=381501602 nodes=[2338081031, ...]>

asked 07 Oct '17, 17:19

Druzhba's gravatar image

Druzhba
150111118
accept rate: 0%


Overpass appends a center element to the way:

<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="Overpass API"> <note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note> <meta osm_base="2017-10-07T18:59:02Z"/> <way id="381501602"> <center lat="49.2559306" lon="8.4525152"/> <nd ref="2338081031"/> <nd ref="2338081030"/>

You'll have to see if overpy supports this element or not. It seems to: https://python-overpy.readthedocs.io/en/latest/api.html#elements

permanent link

answered 07 Oct '17, 20:08

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

edited 07 Oct '17, 20:09

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×228
×78
×4

question asked: 07 Oct '17, 17:19

question was seen: 3,425 times

last updated: 07 Oct '17, 20:09

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum