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

Please I need help. See the code below:

query = "way(%s, %s, %s, %s);(._;>;);out geom;" % ( lat_min, lon_min, lat_max, lon_max )["highway"="footway"]

result=api.query(query)

My name is to use the four coordinates (lat_min, lon_min, lat_max, lon_max )to create a rectangular boundary for extracting particular highway information (e.g. footway), but I kept getting error on the syntax.

Please what are am i doing wrongly?

asked 17 Feb '22, 15:11

Segunlakata's gravatar image

Segunlakata
16131316
accept rate: 0%

edited 17 Feb '22, 16:56

alester's gravatar image

alester
6.6k266100

1

I think you need to provide more information "%s" is not overpass syntax so I presume you are building queries in something like php or python. Can you capture an example of the generated query & show that instead?

(17 Feb '22, 15:32) SK53 ♦

Supplementary information has been provided in a closed question here: https://help.openstreetmap.org/questions/83512/overpass-api

(18 Feb '22, 08:43) InsertUser

I don't know python, but...

If you're making one call:

way(49.89367,-97.212781,49.907792,-97.19422)[highway=footway];
(._;>;);
out geom;

If you need a global bbox for multiple calls

[bbox:49.89367,-97.212781,49.907792,-97.19422];

If you want to define a multi-sided polygon:

way(poly:"51.4591971 -0.9723236 51.7053402 -0.6110287 51.6639446 -0.3961114")[highway=unclassified];
(._;>;);
out geom;

PS When you next post a question can you provide a routine which doesn't return empty. It makes it hard to determine any errors.

permanent link

answered 17 Feb '22, 20:39

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

Yes, I am using python. I wrote use this code below and it is working fine for me.

import overpy
import json
from copy import deepcopy
import haversine as hs
import math


api = overpy.Overpass()
#generate an intended map boundary for a given coordinates

result = api.query (f'way(around:100,49.8974309,-97.2033944 )["highway"="footway"];(._;>;);out geom;')

where, radius=100m latitude =49.8974309 longitude=-97.2033944

But now, i do not want to use radius again, rather i want to use four coordinates like a rectangular bounding box to query osm for highway (e.g. footway in particular, in the specified area) using python.

permanent link

answered 17 Feb '22, 16:06

Segunlakata's gravatar image

Segunlakata
16131316
accept rate: 0%

edited 17 Feb '22, 16:55

alester's gravatar image

alester
6.6k266100

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:

×54

question asked: 17 Feb '22, 15:11

question was seen: 1,186 times

last updated: 18 Feb '22, 08:43

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