NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi OSM community,

I am totally new to Geodata and gis, so please try to answer even if its a dumb question.

My task is to find the distance between 2 given addresses using osm.

What I have done so far ?

  1. Downloaded osm.pbf file for my region
  2. Imported it to local postgresql postgis enabled database with different tables (planet_osm_line, planet_osm_nodes, planet_osm_point, planet_osm_polygon.. etc)

Approach for my task:

So to calculate the distance between 2 points I thought of gecoding the addresses first and then use st_distance() to find the distance between the 2 points. (Please correct me if my approach is not advisable)

Where I am stuck ?

To select the polygon using the postal code, I thought of filtering it through postal_code. Unfortunately it does not have a column named postal_code. So how could I achieve this using the above mentioned tables and geocode the address.

EDIT 1: Or is it possible to just extract "addr:city", "addr:country", "addr:housenumber", "addr:housename", "addr:postcode", "addr:street", "lat", "lon"fields from osm file using osmconvert and then query against it to get the lat/lon ?

asked 01 Feb '17, 15:25

3yK's gravatar image

3yK
11448
accept rate: 0%

edited 01 Feb '17, 15:54


It is of course possible to extract the addresses. Take a look at http://wiki.openstreetmap.org/wiki/Nominatim

It depends on where you are located, but there is a good chance that there won't be polygon features associated with postal codes, or perhaps even much address data at all.

permanent link

answered 01 Feb '17, 16:12

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

But the installation of nominatim seems a little bit complicated. My query looks simple.

Is it possible to geocode using the question I asked in the section EDIT 1 ? will it miss some data ?

What are the advantages of using nominatim over manual querying ?

(01 Feb '17, 16:42) 3yK
1

You can investigate the results nominatim returns using the public server:

http://nominatim.openstreetmap.org/

nominatim builds on the osm2pgsql schema that you have used above, adding indexes and associations that are not necessarily explicitly given in any of the osm2gpsql tables. So what you are doing is starting to implement pieces of what nominatim does.

(01 Feb '17, 17:01) maxerickson
1

Nominatim takes the same data as you did but processes and stores it in such a way that geocoding is fast. This includes combining information from different types of relations and objects.

Postal code boundaries as mapped as separate relations in some countries (e.g. Germany, part of Belgium). This technique is not possible in e.g. the USA and the UK where zip codes are not areas.

(02 Feb '17, 12:04) escada

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×263
×134

question asked: 01 Feb '17, 15:25

question was seen: 6,207 times

last updated: 02 Feb '17, 12:04

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum