Database Reference
In-Depth Information
Importing OpenStreetMap data with the
osm2pgsql command
Inthisrecipe,youwillimport OpenStreetMap ( OSM )datatoPostGISusingthe os-
m2pgsql command.
YouwillfirstdownloadasampledatasetfromtheOSMwebsite,andthenyouwillim-
port it using the osm2pgsql command.
You will add the imported layers in a GIS Desktop software and generate a view to
getsubdatasets,usingthe hstore PostgreSQLadditionalmoduletoextractfeatures
based on their tags.
Getting ready
Weneedthefollowinginplacebeforewecanproceedwiththestepsrequiredforthe
recipe:
1. Install osm2pgsql .IfyouareusingWindows,followtheinstructionsavailable
at http://wiki.openstreetmap.org/wiki/Osm2pgsql .IfyouareonLinux,youcan
installitfromtheprecedingwebsiteorfrompackages.Forexample,forDebi-
an distributions, use the following:
$ sudo apt-get install osm2pgsql
2. For more information about the installation of the osm2pgsql command for
theotherLinuxdistributions,MacOSX,andMSWindows,pleaserefertothe
osm2pgsql webpageavailableat http://wiki.openstreetmap.org/wiki/Osm2p-
gsql .
3. Although,it'smostlikelythatyouwillneedtocompile osm2pgsql yourselfas
the one that is installed with your package manager could already be obsol-
ete.InmyLinuxMint12box,thiswasthecase(itwas osm2pgsql v0.75),so
IhaveinstalledVersion0.80followingtheinstructionsonthe osm2pgsql web
page. You can check the installed version just by typing the following com-
mand:
Search WWH ::




Custom Search