Data: Raw OSM data (.osm XML file).

Target: Connect between house number represented by node, to street name represented by way.

What I did:

In www.openstreetmap.org I can explore elements. So I point the node representing house number:

enter image description here

Then I searched by it's osm_id and found:

<node id="MY_NODE_ID" visible="true" version="1" changeset="..." timestamp="..." user="..." uid="..." lat="..." lon="...">
    <tag k="addr:housenumber" v="MY_HOUSE_NUMBER"/>

Then I searched this node and as expected I found it part of the building represented as way:

<way id="MY_BUILDING_ID" visible="true" version="1" changeset="..." timestamp="..." user="..." uid="...">
    <nd ref="MY_NODE_ID"/>
    <nd ref="..."/>
    <tag k="building" v="yes"/>

Finally I expect MY_BUILDING_ID to be part of another way representing the street. But MY_BUILDING_ID appears only once in the XML file. So I found street's osm_id and found it in the XML as:

 <way id="MY_STREET_ID" visible="true" version="10" changeset="..." timestamp="..." user="..." uid="...">
  <nd ref="..."/>
  <nd ref="..."/>
  <tag k="highway" v="residential"/>
  <tag k="name:en" v="MY_STREET_NAME"/>
  <tag k="source" v="user via ..."/>

But none of the <nd ref="..."/> isn't MY_BUILDING_ID, and more over none of the <nd ref="..."/> appears again in the XML file.

Conclusion: How to link between known MY_NODE_ID to MY_STREET_ID so later it's easy to make the link between MY_HOUSE_NUMBER and MY_STREET_NAME?

  • 3
    I guess that you should edit OSM data and create an associated street relation for your house wiki.openstreetmap.org/wiki/Relation:associatedStreet. But most addressed are without such relation and if the address is without address:street tag you just can't link the address with the street in a reliable way. Finding the closest street gives often a correct result. – user30184 Nov 22 '15 at 22:12
  • How to find the closest street? Just but shortest distance? Generally it's not always true... – michael Nov 23 '15 at 6:30
  • That's what I meant. Shortest distance gives often a correct result, quite often not. – user30184 Nov 23 '15 at 7:04

Your task to connect the house number automatically to the street name will surely fail in many cases. Just imagine a street crossing with four different named streets, where the house number could be related to any of them.

The only working way is to add the full adress information to the house number during editig, using the Karlsruher Schema.

The information might be added to a node representing the building entrance or the center of the building, or added to the closed way or multipolygon relation representing the building itself. Both methods are accepted, but it is up to the individual mapper to decide how he does it (or not).

Relations of type associated street are another method to combine a street with the house numbers.

You have to keep in mind that a street (of the same name) can be represented by several ways, either direction-wise or one after the other. You have to add all those to the relation.

And, the house number node does not have to be part of the building way.

  • Thanks, Basically what I wanted to do is implement simple geocoder by myself. Because I noticed that in Nominatim when I search for that street number I get the result, I assumed that this data encoded in the raw data. So how do they achieve this if ain't the data in the raw files? – michael Nov 23 '15 at 8:20
  • Have you looked out for associated street relations? – AndreJ Nov 23 '15 at 8:45
  • 1
    @scai one example (I actually spotted this for many nodes): openstreetmap.org/node/1712600303 – michael Nov 23 '15 at 9:07
  • 1
    @michael Yep, that's wrong, i.e. incomplete data. At least the house number and street name should be present, otherwise the data is ambiguous. You can only guess the corresponding street, which Nominatim probably also does. This can and it will fail for some addresses. – scai Nov 23 '15 at 9:16
  • 2
    Yes, see wiki.openstreetmap.org/wiki/Nominatim/… – AndreJ Nov 23 '15 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.