0

I am using overpass API to get amenities around (within radius of 200 m) particular location. I am able to receive the results but for last 8 records (from 20 to 28), i get wrong coordinates. Can somebody help, is there something wrong with query?

import  pandas as pd
from pandas.io.json import json_normalize
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
pd.set_option('display.max_colwidth', 500)
# bounding box coordinates
unique_nodes = []
way_nodes = []
# query overpass within OpenStreetMap
import overpass
api = overpass.API()
data = api.get('(node["amenity"](around:200,51.896723,-8.482056);way["amenity"](around:200,51.896723,-8.482056);relation["amenity"](around:200,51.896723,-8.482056);>;);')
#df = [f for f in data.features  if f.geometry['type'] == "LineString"]
df_1 = json_normalize(data['features'])
df_1 = df_1[df_1['properties.amenity'].notnull()]
df_1 = df_1[df_1['properties.name'].notnull()]
print(df_1[['properties.amenity', 'geometry.coordinates', 'properties.name']])

The results are mentioned below:

   properties.amenity      geometry.coordinates                           properties.name
0             college  [-8.4816139, 51.8950368]        Crawford College of Art and Design
1                taxi  [-8.4797104, 51.8974271]                           Cork Taxi Co-op
2          restaurant  [-8.4829027, 51.8971138]                             Café Paradiso
3         car_sharing  [-8.4792851, 51.8964633]                                Wandesford
4             parking   [-8.481515, 51.8961668]                          Saint Finbarre's
5                 pub    [-8.483117, 51.897028]                             Reidy's Vault
6                 pub  [-8.4801976, 51.8973964]                                 Costigans
8     social_facility  [-8.4813453, 51.8976471]                             Penny Dinners
9      bicycle_rental  [-8.4846434, 51.8971537]                               Dyke Parade
10     bicycle_rental  [-8.4822285, 51.8971562]                     St. Finbarre's Bridge
11     bicycle_rental  [-8.4800657, 51.8964889]                           Wandesford Quay
12           pharmacy  [-8.4802256, 51.8975298]                                  Santry's
13                pub  [-8.4812941, 51.8980821]                               Porterhouse
14          fast_food   [-8.4812901, 51.897902]                                Holy Smoke
17         restaurant  [-8.4797886, 51.8975706]                          Feed your Senses
20             school  [-8.4806982, 51.8982846]             Presentation Brothers College
21         university  [-8.4806982, 51.8982846]                          UCC Lee Maltings
22         university  [-8.4806982, 51.8982846]                Tyndall National Institute
23             school  [-8.4806982, 51.8982846]  Saint Maries of the Isle National School
24             school  [-8.4806982, 51.8982846]                     Saint Aloysius School
25            parking  [-8.4806982, 51.8982846]                           Lancaster Lodge
26            theatre  [-8.4806982, 51.8982846]                                  The Kino
27         university  [-8.4806982, 51.8982846]                   University College Cork
28           hospital  [-8.4806982, 51.8982846]                 Mercy University Hospital


Northern Shadow
  • 303
  • 1
  • 4
  • 16
  • 2
    Rows 20-28 show the coordinates for node 5812678457, rather than any of the ways - obviously your code doesn't handle OSM ways properly. – mmd Feb 03 '19 at 19:45
  • @mmd can you please help ? – Northern Shadow Feb 03 '19 at 19:58
  • i checked the API query on overpass turbo it gives me correct results but through code somehow, it doesn't work – Northern Shadow Feb 03 '19 at 20:03
  • 2
    You should try to get a _single_ way printed correctly in your output, e.g. via the following example: `(way(593534339);>;);` -> returns data for way 593534339 only, like in https://www.openstreetmap.org/api/0.6/way/593534339 – mmd Feb 03 '19 at 20:35
  • i have tested it for single way earlier as well. of course the result that way is correct. but getting them altogether makes it problematic. can you point out mistake in the code ? you appear to be an expert – Northern Shadow Feb 03 '19 at 20:44
  • Maybe use out center mode for ways and relations in Overpass to get the coordinates for the center of the area. – scai Feb 04 '19 at 10:45

0 Answers0