Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support area as geojson #154

Open
TheSnoozer opened this issue Oct 27, 2022 · 3 comments
Open

Support area as geojson #154

TheSnoozer opened this issue Oct 27, 2022 · 3 comments
Assignees
Labels
Milestone

Comments

@TheSnoozer
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.")
@mvexel
Copy link
Owner

mvexel commented Feb 13, 2024

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
Copy link
Author

Thanks a lot!

@TheSnoozer
Copy link
Author

TheSnoozer commented Feb 13, 2024

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-13T22:07:10Z",
    "timestamp_areas_base": "2024-02-13T18: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 :-)

@TheSnoozer TheSnoozer reopened this Feb 13, 2024
@mvexel mvexel self-assigned this Feb 13, 2024
@mvexel mvexel added the geojson label Feb 21, 2024
@mvexel mvexel added this to the 0.8 milestone Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In progress
Development

No branches or pull requests

2 participants