Match streets to cities without area in PBF

Please tell me how to match osm streets and villages without areas from PBF file
Here is the example street: Way: ‪Słupska‬ (‪240777479‬) | OpenStreetMap
If I search it via OSM panel it will give me the hierarchy with city “Dobra”
Buti it is only a node and there is not relation between them

Welcome to the forum!

A .pbf file is a raw dump of nodes, ways and relations and I guess the only way to find the village closest to this Słupska is find all place=village nodes in the .pbf and see which on is the closest by.

I see villages in Poland like this village Dobra are indeed tagged as node only as you noticed. I also see the municipality is Dębnica Kaszubska and that has an area.

What are you searching for the village of or the municipality?

I think you are much better off importing the .pbf into PostgreSQL database with PostGIS support. Using that you can do a spatial query to get your answers.

You could (but that doesn’t mean that you should or would want to) examine address objects (that is building polygons or address nodes), and extract addr:street and addr:city. If this works well depends on

  • having good address coverage (a given in Poland)
  • addr:city being added to the addresses (local mapping practice dependent)
  • addr:city being an actual place and not a postal city (this depends on how your addresses are regulated)
1 Like

Hey, thank you for reply! :slightly_smiling_face:
I use osmium + geopandas for processing but the closest lookup approach can be misleading as it seems to me
My initial aim was to collect all streets for all villages, so matching them became a problem when there is no valid area for the village
And I noticed that OSM search can associate streets with a single node villages
In Nominatim I found distances to different objects for such villages, so maybe you are right that I need just to select the closest place

Hi! Thank you for attention! :slightly_smiling_face:
Maybe I needed to add a context:

Sorry, but I misunderstood that you explained. I use ways to retrieve streets information

The approach I suggested would be, to 1st extract all addresses for a village and then generate a list of streets from that, then extract the streets.

Alternative approach would be to generate the convex hull (Convex hull - Wikipedia) of the addresses for one village and use that to extract the streets, but that is more suited to a situation in which you have the data in a geospatial database.

My expectation would be that this would give far better results than just a distance based approach.

1 Like

Okay, I got it! Thanks for idea!

Before I forget: what you are going to retrieve from OSM as a street, regardless of method, is often not going to be one continuos geometry from beging to end. The OSM data model requires the way elements to be split when attributes (tags) and relation membership change, so typically you will retrieve multiple ways for one “street” that you will have to combine to get a single geometry (or multiple in the case of dual carriageways).

Sorry to bother you
Here I found the children of “Dobra” that contain streets
Maybe you know how to get them from osm data?

Also I started to use addr:street, but addr:city is not ID while addr:city:simc is quite rare tag

Here I found the children of “Dobra” that contain streets

The node that you list:

Does not have childeren, so not sure what you are meaning.

Following @SimonPoole, this overpass query gives you all objects that are tagged with addr:city=Dobra and then: