python-overpy icon indicating copy to clipboard operation
python-overpy copied to clipboard

querying data from local osm file

Open johnbryant1 opened this issue 6 years ago • 4 comments

Hi, I am trying to query the data of a specific osm file from my hard disk. Is it possible to do so directly using overpy without uploading the osm file it to a localhost? Thank you in advance.

johnbryant1 avatar Nov 02 '18 12:11 johnbryant1

`import overpy

with open('test.osm')) as fh: osm_data = api.parse_xml(data=fh.read(), encoding='utf-8', parser=None) `

PolyglotOpenstreetmap avatar Dec 13 '18 22:12 PolyglotOpenstreetmap

I assume the idea of @johnbryant1 is to load a local OSM file and run queries against that (correct me if I am wrong).

I tried

    with open('example.osm') as file_handle:
        osm_data = api.parse_xml(data=file_handle.read(), encoding='utf-8', parser=None)

    api = osm_data.api

but

    api.query(query_str)

seems still to query overpass-api.de instead of running in-memory.

amenk avatar Dec 31 '19 10:12 amenk

Hi, I'm also interested in getting overpy to work while using a local .osm file instead of the online databases. After trying the approaches of @PolyglotOpenstreetmap and @amenk, I couldn't get the query to use my local database.

Does anyone have a solution for this?

Thanks in advance.

armandomiguel avatar May 06 '20 11:05 armandomiguel

Hello, is there any news about this issue? I'm sure it is my fault but I also tried with @PolyglotOpenstreetmap proposal and unfortunately it runs the query against the global server.

Can somebody please shed some light on this? Thank you!

nachoSO avatar Mar 04 '22 16:03 nachoSO