Missing data for geojson - openstreetmap

I made the following query in overpass-turbo
[out:json][timeout:25];
// gather results
(
// query part for: “amenity=hospital”
node["amenity"="hospital"]({{bbox}});
way["amenity"="hospital"]({{bbox}});
relation["amenity"="hospital"]({{bbox}});
);
// print results
out body;
>;
out center;
>;
but unfortunately i do not get all the nodes displayed into geojson.io from extracted geojson data (overpass-turbo).
Any idea that could help me to get all data?
Regards

It looks like http://geojson.io does show nodes but not polygons (= OSM ways). This could be a limitation of http://geojson.io or of the overpass turbo export, I'm not really familiar with the GeoJSON file format.
You can tell overpass to convert ways to nodes with the geometry attribute out center;. Try the following query:
[out:json][timeout:25];
// gather results
(
// query part for: “amenity=hospital”
node["amenity"="hospital"]({{bbox}});
way["amenity"="hospital"]({{bbox}});
relation["amenity"="hospital"]({{bbox}});
);
// print results
out center;
>;

Related

Overpass API: query for counting amenity of specified type around set of lat lons

I'm trying to query data from the OSM Overpass API. Specifically I'm trying to determine the count of amenities of a given type around a point (using the 'around' syntax). When running this for many locations (lat, lons) I'm running into a TooManyRequests error.
I have tried to work around by setting sleep time pauses and playing with the timeout header and retry time, but I'm running into the same issue. I'm trying to find a way to adapt the query so that it just returns the count of amenities (of specified type) around each point, rather than the full json of nodes which is more data intensive. My current script is as follows;
# Running Overpass query for each point
results = {}
for n in range(0, 200):
name = df.loc[n]['city']
state = df.loc[n]['state_name']
rad = df.loc[n]['radius_m']
lat = df.loc[n]['lat']
lon = df.loc[n]['lng']
# Overpass query for amenities
start_time = time.time()
api = overpy.Overpass(max_retry_count=None, retry_timeout=2)
r = api.query(f"""
[out:json][timeout:180];
(node["amenity"="charging_station"](around:{rad}, {lat}, {lon});
);
out;
""")
print("query time for "+str(name)+", number "+str(n)+" = "+str(time.time() - start_time))
results[name] = len(r.nodes)
time.sleep(2)
Any help is much appreciated from other Overpass users!
Thanks
In general, you can run out count; to return a count from an overpass API query.
It's hard to say without knowing how your data is specifically structured, but you might have better luck using area to look at specific cities, or regions.
Here is an example that returns the count of all nodes tagged as charging station in Portland, Oregon:
/* charging stations in portland */
area[name="Oregon"]->.state;
area[name="Portland"]->.city;
(
node["amenity"="charging_station"](area.state)(area.city);
);
out count;

overpass-turbo Limit to State?

I am trying to export all admin_level=6 using OverpassAPI.
However I am noticing a small issue as I can't seem to only show results for 1 state.
Take NT, Australia it's quite small width wise and the map view when I query it seems to grab some results for WA, QLD as well as NT.
Is there anyway to limit to a state?
Query
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“city”
*/
[out:json][timeout:25];
// gather results
(
// query part for: “city”
node["admin_level" = "6"]({{bbox}});
way["admin_level" = "6"]({{bbox}});
relation["admin_level" = "6"]({{bbox}});
);
// print results
out body;
>;
out skel qt;
End result
When you zoom out it shows
You can skip bbox and add area filter. Search all supermarkets in NT:
[out:json][timeout:25];
area["state_code"="NT"]["is_in:country_code"="AU"]->.boundaryarea;
(
nwr["shop"="supermarket"](area.boundaryarea);
);
out meta;
>;
out skel qt;

Query from OpenStreetMap

At the moment I'm using the Overpass API to query from OpenStreetMap using https://overpass-turbo.eu/ but when I use the following code, not all the schools in the area appear on the map (e.g. Holy Cross College doesn't appear).
area[name = "Council of the City of Ryde"];
node(area)[amenity = school];
out;
Anyone know why this might be the case?
Thanks for any help!
OpenStreetMap data consists of three basic elements: nodes, ways and relations. Your query searches only for nodes. Some schools will be mapped as ways and a few others as relations.
You have to change your query in order to search for all three elements:
area[name = "Council of the City of Ryde"];
(
node(area)[amenity = school];
way(area)[amenity = school];
relation(area)[amenity = school];
);
out;
Alternatively just use the keyword nwr to search for all three elements:
area[name = "Council of the City of Ryde"];
nwr(area)[amenity = school];
out;
If there are still missing schools then either they are mapped with a different tag or they are missing in OSM. In the second case feel free to add them yourself.

How to retrieve all airports around a given osm-ID

I want to retrieve all airports around a city (g.e. Leipzig) within a radius of 50km.
I tried this
[out:csv(::type,name, 'name', ::id; true; ";")];
(
relation["iata"~".*"](around: 50000, 51.3124404, 12.4131075);
node["iata"~".*"](around: 50000, 51.3124404, 12.4131075);
way["iata"~".*"](around: 50000, 51.3124404, 12.4131075);
);
out;
returns
#type;name;name;#id
way;Flughafen Leipzig/Halle;Flughafen Leipzig/Halle;435715317
relation;Leipzig-Altenburg Airport;Leipzig-Altenburg Airport;6116338
But I want to use the osm-id directly.
When I search within Leipzig (admin_level = 8) and a radius
[out:csv(::type,name, 'name', ::id; true; ";")];
area(3600062649) -> .leipzig;
way(around.leipzig:50000)[iata~".*"]({{bbox}});
out;
I retrieve an empty result set
When I search within saxony (admin_level = 4)
area(3600062467) -> .sachsen;
way(area.sachsen)[iata~".*"]({{bbox}});
out;
then I retrieve
#type;name;name;#id
way;Flughafen Leipzig/Halle;Flughafen Leipzig/Halle;435715317
I want to retrieve the same result like I use the lat/lon-information.
Edit:
I get the expected result by retriving the center-lat/lon of a relation (given by an osm-id) and use this lat/lon-information to retrieve all airports within a given radius.
Now I want to skip the step "retrieve center-lat/lon". I want to use the osm-id of a relation and a given radius directly to retrieve all airports within a given radius.
#mmd: I hope it's more understandable.

postgis convert Points to polygon

what is the easy way to convert points to polygon?
i've tried this query
SELECT ST_GeomFromText('POLYGON((157 -536.0,157 -537.0,157 -538.0,157 -539.0,157 -540.0,157 -541.0,157 -542.0,157 -543.0,157 -544.0,157 -545.0,158 -545.0,159 -545.0,160 -545.0,161 -545.0,162 -545.0,163 -545.0,164 -545.0,165 -545.0,165 -544.0,165 -543.0,165 -542.0,165 -541.0,165 -540.0,165 -539.0,165 -538.0,165 -537.0,165 -536.0,164 -536.0,163 -536.0,162 -536.0,161 -536.0,160 -536.0,159 -536.0,158 -536.0,157.0 -536.0))');
but its results are not as expected as shown below
which is supposed to be like this
Obviously your points are not in the correct order to define a polygon., and as the commenter pointed out, you have more than one polygons.
You could divide them into sets that make each polygon (manually?), and construct a multipolygon as follows:
SELECT ST_AsText(ST_Collect(ARRAY[ST_GeomFromText('POLYGON(..first polygon...)'),ST_GeomFromText('POLYGON(..2nd polygon...)',...,ST_GeomFromText('POLYGON(..last polygon...)')]));