Mapnik/Installation on Fedora 18

From OpenStreetMap Wiki
Jump to: navigation, search
Available languages — Mapnik/Installation on Fedora 18

Tested at

  • July 3, 2013


  • Install and run the database server if you haven't done this before (as root)
yum install postgresql-server
postgresql-setup initdb
systemctl start postgresql

Optionally set the service to start automatically

systemctl enable postgresql
  • Install the postgres postgis extension (as root)
    yum install postgis
  • Setup the database

optionally, set password for the database user (as root)

    passwd postgres

otherwise run "su - postgres" as root

su - postgres
createdb -EUNICODE gis
createuser -S -D -R apache
echo "GRANT ALL ON SCHEMA PUBLIC TO apache;" | psql gis
psql gis < /usr/share/pgsql/contrib/postgis-64.sql
psql gis < /usr/share/pgsql/contrib/spatial_ref_sys.sql
echo "grant all on geometry_columns to apache;" | psql gis
echo "grant all on spatial_ref_sys to apache;" | psql gis

Note - on a 32 bit system change postgis-64.sql to postgis.sql on the 6th line above.

  • Create your OSM working dir and checkout osm2pgsql project
mkdir ~/osm
cd ~/osm
svn co
cd osm2pgsql
  • Import the map.osm into the gis database
cp -r ~/osm/osm2pgsql /tmp
cp ~/osm/map.osm /tmp
./osm2pgsql -S ./ ../map.osm
  • Install mapnik
yum install mapnik mapnik-devel mapnik-python proj-epsg
  • Checkout mapnik data from svn
cd ~/osm
svn co
  • Download the Coastline data
  • Files required since June 2010
  • Unpack them up properly
cd ~/osm/mapnik
tar xvzf world_boundaries-spherical.tgz
tar xvjf processed_p.tar.bz2 -C world_boundaries
tar xvjf shoreline_300.tar.bz2 -C world_boundaries
unzip -d world_boundaries
unzip -d world_boundaries
  • Setup the mapnik environment
cd ~/osm/mapnik
cp archive/set-mapnik-env .
vim set-mapnik-env
change "export MAPNIK_DBNAME='osm'" to 'gis'
change "export MAPNIK_DBUSER=`whoami`" to 'apache'
  • Test mapnik
   cp ~/osm/mapnik/ ~/osm/mapnik/
   vim ~/osm/mapnik/
   # Change the following for different bounding boxes and zoom levels
   # Start with an overview
   # World
   bbox = (-180.0,-90.0, 180.0,90.0)
   render_tiles(bbox, mapfile, tile_dir, 0, 5, "World")
   Change the 5 to 0, then
   Comment out all of the render_tiles line that follows with a '#'
  • Copy/run mapnik
cp -r ~/osm/mapnik ~
cd ~/mapnik/
source set-mapnik-env
  • Check file tiles/0/0/0.png is a world map image