2
2
Fork
You've already forked overpass-api-python-wrapper
2

Support area as geojson #154

Closed
opened 2022年10月27日 21:07:21 +02:00 by TheSnoozer · 5 comments
TheSnoozer commented 2022年10月27日 21:07:21 +02:00 (Migrated from github.com)
Copy link
[out:json][timeout:25];
// gather results
(
 // (around:radius,latitude,longitude)
 is_in(43.5391108,6.9376076);
);
// print results
out body;
>;
out skel qt;

returns valid data (e.g. area) however the api just states overpass.errors.UnknownOverpassError: Received corrupt data from Overpass (invalid element).

Besides that a better error message would be:

raise UnknownOverpassError(f"Received element {elem_type=} which is currently not implemented, or represents corrupted data.")
``` [out:json][timeout:25]; // gather results ( // (around:radius,latitude,longitude) is_in(43.5391108,6.9376076); ); // print results out body; >; out skel qt; ``` returns valid data (e.g. `area`) however the api just states `overpass.errors.UnknownOverpassError: Received corrupt data from Overpass (invalid element)`. Besides that a better error message would be: ``` raise UnknownOverpassError(f"Received element {elem_type=} which is currently not implemented, or represents corrupted data.") ```

This should be solved on the main branch now after merging #140. Haven't tested extensively but

import overpass
api = overpass.API(responseformat="geojson")
query = "is_in(43.5391108,6.9376076);out body;>;"
resp = api.get(query)

returns the GeoJSON (you'd have to json.dumps() the dict to get a valid JSON string.

We'll get these improvements out in the next release 0.7.1.

This should be solved on the main branch now after merging #140. Haven't tested extensively but ``` import overpass api = overpass.API(responseformat="geojson") query = "is_in(43.5391108,6.9376076);out body;>;" resp = api.get(query) ``` returns the GeoJSON (you'd have to `json.dumps()` the dict to get a valid JSON string. We'll get these improvements out in the next release 0.7.1.
TheSnoozer commented 2024年02月13日 22:40:40 +01:00 (Migrated from github.com)
Copy link

Thanks a lot!

Thanks a lot!
TheSnoozer commented 2024年02月13日 23:15:38 +01:00 (Migrated from github.com)
Copy link

Sorry I closed this too early. It seems the "area" information is not available.

Consider:

import overpass
import pprint
api = overpass.API(responseformat="geojson", debug=True)
query = "is_in(43.5391108,6.9376076);out body;>;"
pprint.print(api.get(query, verbosity="skel qt"))

which seems to run the following query:

[out:json];is_in(43.5391108,6.9376076);out body;>;out skel qt;

result is:

{'features': [{'geometry': {'coordinates': [[[6.9363278, 43.5388949],
 // SNIP
 [6.9363278, 43.5388949]]],
 'type': 'Polygon'},
 'properties': {'id': 494418615,
 'nodes': [3812825108,
 // SNIP
 3812825108],
 'tags': {'landuse': 'residential'},
 'type': 'way'},
 'type': 'Feature'}],
 'type': 'FeatureCollection'}

when using the same query with curl:

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'data=%5Bout%3Ajson%5D%3Bis_in%2843.5391108%2C6.9376076%29%3Bout+body%3B%3E%3Bout+skel+qt%3B' https://overpass-api.de/api/interpreter
{
 "version": 0.6,
 "generator": "Overpass API 0.7.61.5 4133829e",
 "osm3s": {
 "timestamp_osm_base": "2024年02月13日T22:07:10Z",
 "timestamp_areas_base": "2024年02月13日T18:32:04Z",
 "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
 },
 "elements": [
{
 "type": "way",
 "id": 494418615,
 "nodes": [
 3812825108,
 // SNIP
 3812825108
 ],
 "tags": {
 "landuse": "residential"
 }
},
{
 "type": "area",
 "id": 3600007385,
 "tags": {
 "ISO3166-2": "FR-06",
 "admin_level": "6",
 "alt_name:de": "Meeralpen",
 "border_type": "departement",
 "boundary": "administrative",
 "name": "Alpes-Maritimes",
....

The id 3600007385 (area) is not included in the results provided by overpass.API.
Thanks :-)

Sorry I closed this too early. It seems the "area" information is not available. Consider: ```python import overpass import pprint api = overpass.API(responseformat="geojson", debug=True) query = "is_in(43.5391108,6.9376076);out body;>;" pprint.print(api.get(query, verbosity="skel qt")) ``` which seems to run the following query: ``` [out:json];is_in(43.5391108,6.9376076);out body;>;out skel qt; ``` result is: ``` {'features': [{'geometry': {'coordinates': [[[6.9363278, 43.5388949], // SNIP [6.9363278, 43.5388949]]], 'type': 'Polygon'}, 'properties': {'id': 494418615, 'nodes': [3812825108, // SNIP 3812825108], 'tags': {'landuse': 'residential'}, 'type': 'way'}, 'type': 'Feature'}], 'type': 'FeatureCollection'} ``` when using the same query with curl: ``` curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'data=%5Bout%3Ajson%5D%3Bis_in%2843.5391108%2C6.9376076%29%3Bout+body%3B%3E%3Bout+skel+qt%3B' https://overpass-api.de/api/interpreter { "version": 0.6, "generator": "Overpass API 0.7.61.5 4133829e", "osm3s": { "timestamp_osm_base": "2024年02月13日T22:07:10Z", "timestamp_areas_base": "2024年02月13日T18:32:04Z", "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL." }, "elements": [ { "type": "way", "id": 494418615, "nodes": [ 3812825108, // SNIP 3812825108 ], "tags": { "landuse": "residential" } }, { "type": "area", "id": 3600007385, "tags": { "ISO3166-2": "FR-06", "admin_level": "6", "alt_name:de": "Meeralpen", "border_type": "departement", "boundary": "administrative", "name": "Alpes-Maritimes", .... ``` The id 3600007385 (area) is not included in the results provided by overpass.API. Thanks :-)

Consolidating this into #181 for 0.8 GeoJSON hardening (relations/multipolygons/routes/boundaries). Closing as duplicate.

Consolidating this into #181 for 0.8 GeoJSON hardening (relations/multipolygons/routes/boundaries). Closing as duplicate.

Duplicate of #181

Duplicate of #181
Sign in to join this conversation.
No Branch/Tag specified
main
tutorial/d1-httpx-nvim
0.8.x
dev-contributor-tooling
1.0-dev
dev
feature/api-modernization
maintenance/base-0.8
maintenance/geojson-fixtures
archive/async-models
maintenance/endpoint-guard
maintenance/live-query-tool
maintenance/modernize-plan
archive/dev-prebaseline-20260502
archive/modernize
archive/chore-tests
chore/poetry
archive/readme
v0.8.2
v0.8.1
v0.8.0
v0.7.2
0.7.1
0.7.0
0.6.1
0.6.0
0.5.7
0.5.6
0.5.5
0.4.0
0.1.0
0.0.2
0.0.1
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mvexel/overpass-api-python-wrapper#154
Reference in a new issue
mvexel/overpass-api-python-wrapper
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?