General instructions are here: http://wiki.openstreetmap.org/wiki/Osm2pgsql#Mac_OS_X
Note: I'm running Snow Leopard (10.6.6 )
1. Install homebrew
Check that you don't have it already:
$ which brew
If you don't have homebrew
install it from here:
E.g. like this:
$ ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
2. Install proj
$ brew install proj $ which proj /usr/local/bin/proj
3. Install geos
$ brew install geos
4. Install osm2pgsql
First add pg_config
to the path, then install osm2pgsql:
$ PATH=$PATH:/Library/PostgreSQL/9.0/bin/ $ brew install osm2pgsql $ which osm2pgsql /usr/local/bin/osm2pgsql
You should now have osm2pgsql installed.
Import OSM data into PostgreSQL
I did the following to import OSM data into PostgreSQL.
# create a user for the osm database createuser -U postgres osm-user # create the osm database createdb -U postgres -E utf8 -O osm-user osm # download som osm data from cloudmade.com, I chose Copenhagen, Denmark. wget http://downloads.cloudmade.com/europe/northern_europe/denmark/copenhagen/copenhagen.osm.bz2 # unzip it bzip2 -d copenhagen.osm.bz2 # install the mercator projection 900913 on the database wget http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/900913.sql psql -U postgres -d osm -f 900913.sql # install PostGIS on database psql -U postgres -d osm -f /Library/PostgreSQL/9.0/share/postgresql/contrib/postgis.sql # find the style to use with osm2pgsql brew list osm2pgsql # list locations installed by homebrew, including location of the default style # Ready to import! use -s if you chose a large OSM dataset, this keeps RAM usage down. # Use location of style file found with brew list osm2pgsql osm2pgsql -d osm -U postgres -S /usr/local/Cellar/osm2pgsql/HEAD/share/osm2pgsql/default.style copenhagen.osm |
You should now have some OSM data in your PostgreSQL database.
Pingback: Mixed bag #1 » Blog for Geodelivery project