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

I would like to write a query that takes the lateral and longitudinal gps coordinates as variables. I have tried it as followed :

lat = 30.74797
long = 53.81236
import overpy
api = overpy.Overpass()

result = api.query("""
way(around:5,""" + lat + """ , """ + long + """)
  ['highway']
  ['highway' !~ 'path']
  ['highway' !~ 'steps'];
(
  ._;
  >;
);
out;""")

Unfortunately it does not work as expected.

How could I manage that ? Thanks

asked 17 Dec '20, 14:32

Dykay's gravatar image

Dykay
36337
accept rate: 0%

edited 17 Dec '20, 14:34


Format strings are a nice way to solve this problem:

https://docs.python.org/3.4/library/string.html#format-string-syntax

I'd suggest using keywords so that you don't have to remember what order to pass in the values, so

"""way(around:5, {lat}, {long})...""".format(lat=lat,long=long)
permanent link

answered 17 Dec '20, 17:30

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

Thank you @maxerickson

(17 Dec '20, 17:52) Dykay

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:

×483
×3
×2

question asked: 17 Dec '20, 14:32

question was seen: 1,200 times

last updated: 17 Dec '20, 17:52

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