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

Question: Get all nodes within a bounding box #14

Open
betsch85 opened this issue Oct 13, 2023 · 3 comments
Open

Question: Get all nodes within a bounding box #14

betsch85 opened this issue Oct 13, 2023 · 3 comments

Comments

@betsch85
Copy link

While reading through the docs a few days ago I thought I saw a function to query all nodes within a bounding box, and now, for the life of me, I can't seem to find it. But maybe I misremembered, is there such a function?

i.e. instead of having a data file for city 1 through N I want a to load a PBF from a whole country and then query different bounding boxes for cities 1 through N

@sebkur
Copy link
Member

sebkur commented Oct 14, 2023

Maybe you we're looking at https://jaryard.com/projects/osm4j/tutorial/cli-reference.html before.

There's the CLI utility OsmBboxFilter that you can install from the utils module using ./install.sh and that offers functionality for extracting bbox data from bigger data sets.

You can also run your data extraction in code and use a BboxFilter to filter your data.

Depending on what you do, it might also be more efficient to build an extraction data structure from you country data file and run bbox queries on that file-based extraction data structure. That is documented here: https://github.com/topobyte/osm4j/tree/master/extra

The run times given there are for the huge planet file. For country files that process is a lot faster (but it won't return data with 100% integrity because the country extracts from Geofabrik are already missing some ways and nodes). In addition to OsmExtraQueryRegion documented there, we also have OsmExtraQueryBbox for extracting rectangular areas.

@sebkur
Copy link
Member

sebkur commented Oct 14, 2023

and of course if you're working with small cities where the Overpass API is an option, that's probably the quickest solution: https://jaryard.com/projects/osm4j/tutorial/rendering-a-map.html

@betsch85
Copy link
Author

Maybe you we're looking at https://jaryard.com/projects/osm4j/tutorial/cli-reference.html before.

There's the CLI utility OsmBboxFilter that you can install from the utils module using ./install.sh and that offers functionality for extracting bbox data from bigger data sets.

You can also run your data extraction in code and use a BboxFilter to filter your data.

Depending on what you do, it might also be more efficient to build an extraction data structure from you country data file and run bbox queries on that file-based extraction data structure. That is documented here: https://github.com/topobyte/osm4j/tree/master/extra

The run times given there are for the huge planet file. For country files that process is a lot faster (but it won't return data with 100% integrity because the country extracts from Geofabrik are already missing some ways and nodes). In addition to OsmExtraQueryRegion documented there, we also have OsmExtraQueryBbox for extracting rectangular areas.

Thanks!

and of course if you're working with small cities where the Overpass API is an option, that's probably the quickest solution: https://jaryard.com/projects/osm4j/tutorial/rendering-a-map.html

Yes I'm planning to do that for the initial data, but I don't want to query the API again for a subset of the data I already have in memory, that seems like a waste of time

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

2 participants