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

Write to file #75

Open
antifa-ev opened this issue Jul 25, 2018 · 4 comments
Open

Write to file #75

antifa-ev opened this issue Jul 25, 2018 · 4 comments

Comments

@antifa-ev
Copy link

Is it possible to dump the output to a GeoJSON file?

@ccamara
Copy link

ccamara commented Mar 7, 2019

I am also wondering the same: I am pretty new to python (just landed to it) and I would like to make a query to Overpass and store the results in a geospatial format (e.g. GeoJSON).

After reading this documentation page I came up with the following code:

import overpy

API = overpy.Overpass()

# Fetch highways within Granollers' city.
result = API.query("""
    area[name="Granollers"][admin_level=8];
    // query part for: “highway=*”
    (way["highway"](area);
    relation["highway"](area);
    );
    // print results
    out body;
    """)

Unfortunately, I am not familiar at all with python and I don't know how to store result as a GeoJSON file (Honestly, I don't even know what kind of thing result is -I tried with type(result) and I get overpy.Result as an output, which doesn't mean much to my poor knowledge). I have been reading overpy documentation but I haven't been able to figure it out.

@diegocrzt
Copy link

There is a library to do osm to geojson osmtogeojson, but it requires to have the raw data (xml or json) as returned by Overpass API. I consider that doing geojson conversion is probably off-topic for overpy, but could be nice to have something like a raw str result returned from overpy to use as input for other tools like osmtogeojson

@clement-igonet
Copy link

There is a library to do osm to geojson osmtogeojson, but it requires to have the raw data (xml or json) as returned by Overpass API. I consider that doing geojson conversion is probably off-topic for overpy, but could be nice to have something like a raw str result returned from overpy to use as input for other tools like osmtogeojson

osmium-tools with "export" command is not well known but do the same (osm to geojson) efficiently (c compiled).

@marcelharing
Copy link

There is a library to do osm to geojson osmtogeojson, but it requires to have the raw data (xml or json) as returned by Overpass API. I consider that doing geojson conversion is probably off-topic for overpy, but could be nice to have something like a raw str result returned from overpy to use as input for other tools like osmtogeojson

Overpass Python Wrapper gives back GEOJSON and also raw XML/JSON data in just a few lines of code.
https://github.com/mvexel/overpass-api-python-wrapper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants