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:19

Druzhba's gravatar image

Druzhba
111
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, 20:08

maxerickson's gravatar image

maxerickson
6.6k74796
accept rate: 29%

edited 07 Oct, 20:09

Your answer
toggle preview

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:

×61
×36
×1

question asked: 07 Oct, 17:19

question was seen: 85 times

last updated: 07 Oct, 20:09

powered by OSQA