osmcode / pyosmium

Python bindings for libosmium
https://osmcode.org/pyosmium
BSD 2-Clause "Simplified" License
318 stars 65 forks source link

Passing bounding box to filter the data #191

Closed sahyagiri closed 2 years ago

sahyagiri commented 2 years ago

Is there a mapped function equivalent to osmium extract -b 2.25,48.81,2.42,48.91 in the pyosmium?

Can we have something like apply_file(openstreetmap_pbf_file_name,locations=True, bounding_box:Box) and return everything within the boundary

If I solve this, I could write utilities in python and spatialite which can benefit many initiatives in python

joto commented 2 years ago

It seems you know osmium, so you are aware that creating extracts is much more complex than a simple bounding box parameter, just look at the many parameters of osmium extract. Adding all this to PyOsmium would make it much more complex and doesn't really help much, because there is a perfectly reasonable tool, i.e. osmium extract to do that work. Not every tool has to do everything, use each tool for what it was designed for and together you can do a lot of things.

sahyagiri commented 2 years ago

It seems you know osmium, so you are aware that creating extracts is much more complex than a simple bounding box parameter, just look at the many parameters of osmium extract. Adding all this to PyOsmium would make it much more complex and doesn't really help much, because there is a perfectly reasonable tool, i.e. osmium extract to do that work. Not every tool has to do everything, use each tool for what it was designed for and together you can do a lot of things.

Thanks a lot for the quick reply. Yes. I have gone through the codes of osmium-tool and libosmium. I was amazed by the speed of osmium-tool vs the python tools like Pyrosm or esy-osm-pbf. I also understand that this repository is python port of libosmium. I have never tried pybind11 before. If I could make osmium-tool port using pybind11 in similar manner, I will post it.

lonvia commented 2 years ago

I'm closing this as a 'won't fix'. Please use osmium-tool to preprocess your files. pyosmium is better suited to do work on pre-filtered data.