Given a city name, I'm trying to extract all nodes and ways that are located inside this city. But instead of a polygon shaped region, I want all elements inside the bounding box that surrounds this polygon shaped city region. I checked out Osmium-tool, but it only provides two functionalities:
The first only returns the data inside the polygon shaped region and the second requires bounding box coordinates. So is there a lib or a tool to extract that data or at least finds bounding box coordinates for a given city? Thanks in advance! asked 16 Dec '21, 10:32 PoRouS |
Thank you both for the very fast answers! @SimonPoole Yes, given the coordinates of the polygon nodes would make it easy to calculate a bounding box. But osmium tags-filter just filters and extracts the nodes into a file, so I don't have direct access to the coordinates, only afterwards. I was hoping that there is a functionality that handles that for me. @Jochen Topf If I filter the country map for the city relation, then the bounding box of the resulting OSM file still contains the values of the whole country and not that of the extracted relation. So probably I can solve it that way: But unfortunately, I'm struggling to access the nodes of a relation in libosmium. I hope you can give me a hint.
} answered 17 Dec '21, 11:04 PoRouS You can use
(17 Dec '21, 12:57)
Jochen Topf
Thanks again for the hint. I found another way using libosmium to find the nodes for a specified relation. My code is based on this example: https://github.com/osmcode/libosmium/blob/master/examples/osmium_area_test.cpp I adapted the area callback to the following to gather the bounding box:
For the germany map this query takes pretty long, so I reduced the map beforehand with osmium-tool by filtering out relations that I need:
(20 Dec '21, 09:33)
PoRouS
|
Determining a bounding box for a polygon is kind of trivial. If you have the polygon in any kind of textual representation it should only take minutes in your favorite scripting language to determine the required values. So the problem is more finding the polygon data for the specific city, in many countries you should be able to get that from OSM itself, in other places you might need to use 3rd party sources or simply draw a bounding box yourself. answered 16 Dec '21, 18:48 SimonPoole ♦
(16 Dec '21, 18:55)
Jochen Topf
|