Loading…
Tilbage

Profilbillede

Finding a building's polygon

Dmytro Gokun

Hi all,

I'm trying to find a building closest to a given (lat, long) within some radius (say, 50 meters). For example, I want to examine point (57.45366, 10.019616). For that, I issue the following DAWA API request: 

http://dawa.aws.dk/adgangsadresser/reverse?x=10.019616&y=57.45366&format=geojson&struktur=mini

The answer is:

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [
      10.02005771,
      57.45294072
    ]
  },
  "crs": {
    "type": "name",
    "properties": {
      "name": "EPSG:4326"
    }
  },
  "properties": {
    "id": "0a3f509a-6b07-32b8-e044-0003ba298018",
    "status": 1,
    "vejkode": "0768",
    "vejnavn": "Farøvej",
    "adresseringsvejnavn": "Farøvej",
    "husnr": "29",
    "supplerendebynavn": null,
    "postnr": "9800",
    "postnrnavn": "Hjørring",
    "kommunekode": "0860"
  }
}

So, the coordinates of the building are (57.45294072, 10.02005771) which is ~84 meters away from the point i'm testing. But, if we look at the map:

https://www.google.com/maps/place/57%C2%B027'13.2%22N+10%C2%B001'10.6%22E/@57.4539162,10.0201285,19z/data=!4m5!3m4!1s0x0:0x0!8m2!3d57.45366!4d10.019616

we can see that the building is clearly within 50 meters to the point. The reason we get distance 84 meters is that the building coordinates are taken from its opposite side and the building is fairly big.

So, in fact, in order to find the correct distance from a point to a building, we need to know the building's polygon, not just one point. I was looking through DAWA API documentation, but was not able to find a way to obtain this information. Partly, because Danish is not my native language :).

Any help is greatly appreciated.

Best regards,
Dmytro.

 

Hi Finn,

thanks for the quick answer. This API looks very much like what i need. The only thing that is missing is the building's address. I've tried https://dawa.aws.dk/bygninger/101771699, but that only returns zip code & city name, no street name/house number.

In fact, after some thinking: I may not need the building's polygon. What I really need is the "true" distance from my point to the building that takes into account the building's shape (polygon) and not just some arbitrary lat/lng within it. Also, I need the address of that building - at the end, the address is what I'm looking for here. If you think about it - that is how reverse geocoding should work: it should consider addresses as polygons and not as points + return the true distance (or have a "radius" parameter). 

Dmytro.

Hi Dmytro

The building API gives you the access addresses (adgangsadresser) contained in the building's polygon. The access addresses (adgangsadresser) are not included in the "flat" format. You can use the parameter struktur=nested:

https://dawa.aws.dk/bygninger?x=10.019616&y=57.45366&n%C3%A6rmeste&format=geojson&struktur=nestet

In your example, the building is not associated with any address, but if you look at, for example, this:

https://dawa.aws.dk/bygninger?x=12.53547185&y=55.70481955&n%C3%A6rmeste&format=geojson&struktur=nestet

Not all buildings have an address, and not all addresses refer to a building.

Kind regards
Finn

ændret af Finn Jordal (05.11.2018)