Version 193 (modified by 11 years ago) ( diff ) | ,
---|
Installation of GIS Tools on Linux
Table of Contents
Suggest these CLI tools for data manipulation:
- GDAL's ogr2ogr, etc
- Convert SRTM to GeoTIFF
GDAL
Simple functionality can be got from the Debian package:
apt-get install gdal-bin
Advanced functionality requires the latest version (install into /usr/local):
apt-get install -y g++ libproj-dev cd /tmp wget http://download.osgeo.org/gdal/1.10.1/gdal-1.10.1.tar.gz tar zxvf gdal-1.10.1.tar.gz cd gdal-1.10.1 ./configure --with-python CPPFLAGS="-fPIC" make make install cd .. ldconfig
Python bindings (e.g. needed for Shapefile Layers and GADM importer) included in above version.
e.g. If you are serving GeoTIFFs larger than 2Gb, you should create an Image Pyramid:
mkdir pyramid ~/gdal-1.10.1/swig/python/scripts/gdal_retile.py -v -s_srs EPSG:4326 -r bilinear -levels 4 -ps 2048 2048 -co "TILED=YES" -co "COMPRESS=JPEG" -targetDir pyramid mygeotiff.tif
PostGIS
PostGIS adds Spatial storage to PostgreSQL (visit this page to configure PostgreSQL before returning here to continue with the GIS parts)
- alternatively these can be installed as part of OpenGeoSuite
NB PostGIS in Debian Lenny is rather old - recommend using the version in Squeeze or Wheezy
Wheezy users:
apt-get install -y postgresql-9.1-postgis su postgres createuser -s -P gis createdb -O gis -E UTF8 gis -T template0 psql -d gis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql psql -d gis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
Squeeze users:
apt-get install -y postgresql-8.4-postgis su postgres createuser -s -P gis createdb -O gis gis createlang plpgsql -d gis psql -d gis -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql psql -d gis -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
Ubuntu users (Lucid/PostgreSQL 8.4/Post-GIS 1.4) - the paths are slightly different
psql -d gis -f /usr/share/postgresql/8.4/contrib/postgis.sql psql -d gis -f /usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql
Add Spherical Mercator projection (900913. See http://www.cadmaps.com/gisblog/?p=81 for 54004):
- Not needed with PostGIS-1.5 :)
psql gis INSERT into spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text) values (900913 ,'EPSG',900913,'GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563,AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], NIT["degree",0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH],AUTHORITY["EPSG","4326"]], PROJECTION["Mercator_1SP"],PARAMETER["semi_minor", 6378137.0], PARAMETER["latitude_of_origin",0.0], PARAMETER["central_meridian", 0.0], PARAMETER["scale_factor",1.0], PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0],UNIT["m", 1.0], AXIS["x", EAST], AXIS["y", NORTH],AUTHORITY["EPSG","900913"]] |','+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs');
Using PostGIS in Sahana
Java
Update: As of version 2.0, a Java Runtime Environment (JRE) is sufficient to run GeoServer. GeoServer no longer requires a Java Development Kit (JDK). Also note, OpenJDK does not work optimally with GeoServer.
for Debian 7 Wheezy:
# Remove OpenJDK & dependent packages apt-get remove openjdk-6-jre-lib # Install a fake package to tell Debian that a valid Java is installed wget http://babel.ls.fi.upm.es/~vpablos/others/packages/debian/oracle-java-pkg-for-debian_1.0.4_all.deb dpkg -i oracle-java-pkg-for-debian_1.0.4_all.deb # Download Sun Java via Browser (need to accept T&C) # http://www.oracle.com/technetwork/java/javase/downloads/server-jre7-downloads-1931105.html http://download.oracle.com/otn-pub/java/jdk/7u25-b15/server-jre-7u25-linux-x64.tar.gz cd /usr/lib/jvm tar zxvf /tmp/server-jre-7u25-linux-x64.gz ln -s /usr/lib/jvm/jdk1.7.0_25 /usr/lib/jvm/java-sun rm /usr/bin/java ln -s /usr/lib/jvm/java-sun/bin/java /usr/bin/java rm /usr/bin/javac ln -s /usr/lib/jvm/java-sun/bin/javac /usr/bin/javac vi /etc/environment JAVA_HOME=/usr/lib/jvm/java-sun export JAVA_HOME
or,
for ubuntu 10.x:
vim /etc/apt/sources.list #uncomment partner repository sudo apt-get update sudo apt-get install sun-java6-jre sudo emacs /etc/environment JAVA_HOME=/usr/lib/jvm/java-6-sun export JAVA_HOME
or,
for debian 6 Squeeze
vim /etc/apt/sources.list # for sun-java packages in unstable deb http://ftp.debian.org/debian/ unstable non-free deb-src http://ftp.debian.org/debian/ unstable non-free apt-get update apt-get install sun-java6-jdk vim /etc/profile JAVA_HOME=/usr/lib/jvm/java-6-sun export JAVA_HOME
The Sun installer will present a license in a curses form. Depending on your terminal emulator, arrow keys may not work for navigation. If not, try ^f and ^b to navigate to the <ok>, and enter to select. Then you'll be asked to accept (or not) the license -- again use ^f or ^b to move to <yes> and hit enter.
or:
- Download the JDK & install it:
cd /usr/local sh ~/jdk-6u21-linux-i586.bin ln -sf /usr/local/jdk1.6.0_21 /usr/local/java vim /etc/profile JAVA_HOME=/usr/local/java export JAVA_HOME
Install the JAI extensions (improves performance for GeoServer WMS), the downloads available are listed here
64-bit:
cd /usr/lib/jvm/java-sun wget http://download.java.net/media/jai/builds/release/1_1_3/jai-1_1_3-lib-linux-amd64-jdk.bin wget http://download.java.net/media/jai-imageio/builds/release/1.1/jai_imageio-1_1-lib-linux-amd64-jdk.bin sh jai-1_1_3-lib-linux-amd64-jdk.bin # accept license export _POSIX2_VERSION=199209 sh jai_imageio-1_1-lib-linux-amd64-jdk.bin # accept license rm jai-1_1_3-lib-linux-amd64-jdk.bin rm jai_imageio-1_1-lib-linux-amd64-jdk.bin
If you installed JRE (sudo sh on Ubuntu)
cd /usr/lib/jvm/java-sun/jre wget http://download.java.net/media/jai/builds/release/1_1_3/jai-1_1_3-lib-linux-amd64-jre.bin sh jai-1_1_3-lib-linux-amd64-jre.bin #accept licence and replace [yes] rm jai-1_1_3-lib-linux-amd64-jre.bin
32-bit:
cd /usr/lib/jvm/java-sun wget http://download.java.net/media/jai/builds/release/1_1_3/jai-1_1_3-lib-linux-i586-jdk.bin wget http://download.java.net/media/jai-imageio/builds/release/1.1/jai_imageio-1_1-lib-linux-i586-jdk.bin sh jai-1_1_3-lib-linux-i586-jdk.bin # accept license export _POSIX2_VERSION=199209 sh jai_imageio-1_1-lib-linux-i586-jdk.bin # accept license rm jai-1_1_3-lib-linux-i586-jdk.bin rm jai_imageio-1_1-lib-linux-i586-jdk.bin
Apache Tomcat
Tomcat is the recommended way to deploy Java applications:
apt-get install -y tomcat7 libtcnative-1 echo 'JAVA_HOME="/usr/lib/jvm/java-sun"' >> /etc/environment echo 'JRE_HOME="/usr/lib/jvm/java-sun/jre"' >> /etc/environment # http://docs.geoserver.org/latest/en/user/production/container.html#optimize-your-jvm vim /etc/default/tomcat7 JAVA_HOME=/usr/lib/jvm/java-sun JAVA_OPTS="-Djava.awt.headless=true -Xmx256m -Xms48m -XX:MaxPermSize=128m -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:+UseConcMarkSweepGC" JAVA_OPTS="-Djava.awt.headless=true -Xmx2g -Xms64m -XX:MaxPermSize=128m -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:+UseConcMarkSweepGC" vim /etc/init.d/tomcat7 TOMCAT7_SECURITY=no # Modify logging vim /etc/tomcat7/server.xml <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" ... ... rotatable="false" /> vim /etc/logrotate.d/tomcat7 /var/log/tomcat7/catalina.out /var/log/tomcat7/localhost_access_log..txt { copytruncate daily rotate 7 compress missingok create 640 tomcat7 adm } /etc/init.d/tomcat7 restart
- Ubuntu 10.x:
sudo apt-get install unzip lynx tomcat6 tomcat6-admin libapache2-mod-jk vim /etc/libapache2-mod-jk/workers.properties workers.java_home=/usr/lib/jvm/java-6-sun /etc/init.d/tomcat6 restart # should see stopping [OK] and starting [OK] # change some permissions cd /var/lib/tomcat6/ sudo chown -R tomcat6:tomcat6 logs work sudo chown tomcat6:tomcat6 /usr/share/tomcat6 # check/change service port - default 8080 /etc/tomcat6/server.xml
Enable access to GeoServer on Port 80 (assuming not using Cherokee):
# if using multiple Tomcats behind a single apache load-balancer apt-get install apache2-mpm-worker a2enmod proxy_ajp a2dissite default vim /etc/tomcat7/server.xml # Uncomment these lines (& add the extra options) <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="off" /> # maxThreads here should match the Apache MPM's MaxClients <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" emptySessionPath="true" enableLookups="false" maxThreads="256" connectionTimeout="45000" /> /etc/init.d/tomcat7 restart vim /etc/apache2/ports.conf NameVirtualHost *:80 Listen 80 vim /etc/apache2/sites-available/geo <VirtualHost *:80> ServerName geo.eden.sahanafoundation.org ServerAdmin webmaster@sahanafoundation.org DocumentRoot /var/www ProxyPreserveHost on # These 2 lines should be disabled in Production ProxyPass /geoserver/ ajp://localhost:8009/geoserver/ ProxyPassReverse /geoserver ajp://localhost:8009/geoserver/ # These lines should be enabled in Production ProxyPass /geoserver/ ajp://localhost:8009/geoserver/gwc ProxyPassReverse /geoserver/gwc ajp://localhost:8009/geoserver/gwc ProxyPass /geoserver/ ajp://localhost:8009/geoserver/wfs ProxyPassReverse /geoserver/wfs ajp://localhost:8009/geoserver/wfs ProxyPass /geoserver/ ajp://localhost:8009/geoserver/wms ProxyPassReverse /geoserver/wms ajp://localhost:8009/geoserver/wms/ ErrorLog /var/log/apache2/geo_error.log LogLevel warn CustomLog /var/log/apache2/geo_access.log combined </VirtualHost> a2ensite geo /etc/init.d/apache2 restart
WMS/WFS
GeoServer
(recommended)
apt-get install unzip wget http://kent.dl.sourceforge.net/project/geoserver/GeoServer/2.4.3/geoserver-2.4.3-war.zip cd /var/lib/tomcat7/webapps unzip ~/geoserver-2.4.3-war.zip /etc/init.d/tomcat7 restart # Allow time to decompress the .war /etc/init.d/tomcat7 stop # Move the data directory somewhere to allow upgrades to happen easily mkdir /var/gis mv /var/lib/tomcat7/webapps/geoserver/data /var/gis/geoserver_data vim /var/lib/tomcat7/webapps/geoserver/WEB-INF/web.xml <!-- Uncomment --> <param-name>GEOSERVER_DATA_DIR</param-name> <param-value>/var/gis/geoserver_data</param-value> /etc/init.d/tomcat7 restart vim /etc/iptables.rules -A INPUT -p tcp --dport 8080 -j ACCEPT reboot
CSS module:
cd /tmp wget http://kent.dl.sourceforge.net/project/geoserver/GeoServer%20Extensions/2.4.3/geoserver-2.4.3-css-plugin.zip cd /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/ unzip /tmp/geoserver-2.4.3-css-plugin.zip /etc/init.d/tomcat7 restart
Add fonts:
cp *.ttf /usr/lib/jvm/java-6-sun/jre/lib/fonts /etc/init.d/tomcat7 restart
GDAL Image Formats (although generally are better off using GDAL to convert to GeoTIFF for serving, if possible):
- http://docs.geoserver.org/latest/en/user/services/wcs/basics.html
cd /tmp wget https://java.net/downloads/imageio-ext/Releases/1.0.5/native-libraries/linux64/imageio-ext-1.0.5-linux64-base-lib.tar.gz mkdir -p /usr/local/lib/imageio-ext cd /usr/local/lib/imageio-ext tar zxvf /tmp/imageio-ext-1.0.5-linux64-base-lib.tar.gz vim /etc/default/tomcat7 LD_LIBRARY_PATH=/usr/local/lib/imageio-ext cd /tmp wget http://kent.dl.sourceforge.net/project/geoserver/GeoServer%20Extensions/2.4.3/geoserver-2.4.3-gdal-plugin.zip cd /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib/ unzip /tmp/geoserver-2.4.3-gdal-plugin.zip /etc/init.d/tomcat7 restart
Cache of downloadable (if main site has issues):
http://geo.host.domain:8080/geoserver
Configure:
- UserGuidelines/GIS/Data
- Production Performance for GeoServer
- Production Performance for GeoWebCache
- Clustering 1
- Clustering 2
Upgrades:
/etc/init.d/tomcat7 stop mv /var/lib/tomcat7/webapps/geoserver ~/geoserver-2.4.0_backup cd /var/lib/tomcat7/webapps unzip ~/geoserver-2.4.3-war.zip /etc/init.d/tomcat7 restart # Allow time to decompress the .war /etc/init.d/tomcat7 stop vim /var/lib/tomcat7/webapps/geoserver/WEB-INF/web.xml <!-- Uncomment --> <param-name>GEOSERVER_DATA_DIR</param-name> <param-value>/var/gis/geoserver_data</param-value> /etc/init.d/tomcat7 restart
MapServer
- TinyOWS can complement this for WFS-T
OpenStreetMap
- http://weait.com/content/build-your-own-openstreetmap-server
- http://weait.com/content/make-your-first-map
- http://dbsgeo.com/foss4g2010/pdf/osm-rendering-foss4g2010.pdf
OpenStreetMap data can be stored in a PostGIS database & rendered using Mapnik.
To support Key/Value pairs:
apt-get install postgresql-contrib-8.4 su postgres psql -d gis -f /usr/share/postgresql/8.4/contrib/hstore.sql
To support Planet diff files:
su postgres psql gis < /usr/share/postgresql/8.4/contrib/_int.sql
Osm2pgsql
It is recommended to use the latest version from source rather than an out of date package:
apt-get install build-essential libxml2-dev libgeos-dev libpq-dev libbz2-dev proj autoconf subversion libtool svn export http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/ Optional (patch updated from original here): http://www.mail-archive.com/dev@openstreetmap.org/msg12768.html #wget http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelinesGISDataLinux/osm2pgsql_centroid.patch cd osm2pgsql #patch -p0 < ../osm2pgsql_centroid.patch ./autogen.sh ./configure sed -i 's/-g -O2/-O2 -march=native -fomit-frame-pointer/' Makefile make make install # Fix needed for SVN version 0.70.5 cp default.style /usr/local/share
Mapnik
- http://wiki.openstreetmap.org/wiki/Mapnik
- http://mike.teczno.com/notes/mapnik.html (Advanced Tips)
0.7.1 is packaged for Squeeze:
apt-get install python-mapnik unzip
Download the OpenStreetMap extensions for Mapnik:
cd svn export http://svn.openstreetmap.org/applications/rendering/mapnik
Download/decompress Coastlines:
cd wget http://tile.openstreetmap.org/world_boundaries-spherical.tgz wget http://tile.openstreetmap.org/processed_p.tar.bz2 wget http://tile.openstreetmap.org/shoreline_300.tar.bz2 wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/10m-populated-places.zip wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/110m-admin-0-boundary-lines.zip cd ~/mapnik tar zxvf ~/world_boundaries-spherical.tgz tar jxvf ~/processed_p.tar.bz2 -C world_boundaries tar jxvf ~/shoreline_300.tar.bz2 -C world_boundaries unzip ~/10m-populated-places.zip -d world_boundaries unzip ~/110m-admin-0-boundary-lines.zip -d world_boundaries
Disable autovacuum:
vim /etc/postgresql/8.4/main/postgresql.conf #autovacuum = on /etc/init.d/postgresql restart
Download/Import area of interest, e.g.:
#wget http://downloads.cloudmade.com/north_america/haiti/haiti.osm.bz2 #su postgres #osm2pgsql -s -d gis haiti.osm.bz2 wget http://labs.geofabrik.de/haiti/2010-11-24-14-43.osm.bz2 su postgres osm2pgsql -s -d gis 2010-11-24-14-43.osm.bz2
Re-enable autovacuum:
vim /etc/postgresql/8.4/main/postgresql.conf autovacuum = on /etc/init.d/postgresql restart
Setup XML file:
cd ~/mapnik ./generate_xml.py --accept-none --dbname gis --symbols ./symbols/ --world_boundaries ./world_boundaries/
Render tiles:
cd ~/mapnik vim generate_tiles.py render_tiles(bbox, mapfile, tile_dir, 0, 8, "World") #minZoom = 10 #maxZoom = 16 #bbox = (-2, 50.0,1.0,52.0) #render_tiles(bbox, mapfile, tile_dir, minZoom, maxZoom) # Haiti bbox = (-74.668, 17.884, -71.659, 20.232) render_tiles(bbox, mapfile, tile_dir, 9, 17, "Haiti") # Muenchen # comment all under here mkdir /var/www/tiles chown postgres /var/www/tiles ln -s /var/www/tiles su postgres MAPNIK_MAP_FILE="osm.xml" MAPNIK_TILE_DIR="tiles/" ./generate_tiles.py
Contours
apt-get install gdal-bin
SRTM3 data:
mkdir ~/mapnik/srtm cd ~/mapnik/srtm wget http://mapnik-utils.googlecode.com/svn@170/sandbox/testing/hillshading/srtm_generate_hdr.sh chmod +x srtm_generate_hdr.sh cp srtm_generate_hdr.sh /usr/local/bin vim process_srtm3.sh #!/bin/bash PREP_TABLE="1" for X in *.hgt.zip; do yes | srtm_generate_hdr.sh $X rm -f "${X%%.zip}" # Import 10m contours rm -f "${X%%.hgt.zip}.shp" "${X%%.hgt.zip}.shx" "${X%%.hgt.zip}.dbf" gdal_contour -i 10 -snodata 32767 -a height "${X%%.hgt.zip}.tif" "${X%%.hgt.zip}.shp" [ "$PREP_TABLE" ] && shp2pgsql -p -I -g way "${X%%.hgt.zip}" contours | psql -q gis shp2pgsql -a -g way "${X%%.hgt.zip}" contours | psql -q gis rm -f "${X%%.hgt.zip}.shp" "${X%%.hgt.zip}.shx" "${X%%.hgt.zip}.dbf" rm -f "${X%%.hgt.zip}.bil" rm -f "${X%%.hgt.zip}.hdr" rm -f "${X%%.hgt.zip}.prj" rm -f "${X%%.hgt.zip}.tif" unset PREP_TABLE done # Haiti wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N17W072.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N18W072.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N18W073.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N18W074.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N18W075.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N19W072.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N19W073.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N19W074.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N19W075.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N20W073.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N20W074.hgt.zip wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N20W075.hgt.zip chown postgres . su postgres sh process_srtm3.sh
Since we are non-commercial, we should be able to use the SRTM4.1 data from CGIAR, however the Shapefile production crashed when it reached 2Gb.
Example for Haiti:
cd ~/mapnik/srtm wget http://srtm.csi.cgiar.org/SRT-ZIP/SRTM_V41/SRTM_Data_GeoTiff/srtm_22_09.zip unzip srtm_22_09.zip gdal_contour -i 10 -snodata 32767 -a height "srtm_22_09.tif" "srtm_22_09.shp" su postgres shp2pgsql -p -I -g way "srtm_22_09" contours | psql -q gis shp2pgsql -a -g way "srtm_22_09" contours | psql -q gis
Configure Mapnik:
vim ~/mapnik/osm.xml # Under line &layer-shapefiles; &layer-contours; vim ~/mapnik/inc/layer-contours.xml.inc <Style name="contours10"> <Rule> &maxscale_zoom14; &minscale_zoom17; <LineSymbolizer> <CssParameter name="stroke">#9cb197</CssParameter> <CssParameter name="stroke-width">0.5</CssParameter> </LineSymbolizer> </Rule> </Style> <Style name="contours50"> <Rule> &maxscale_zoom14; &minscale_zoom17; <LineSymbolizer> <CssParameter name="stroke">#9cb197</CssParameter> <CssParameter name="stroke-width">0.6</CssParameter> </LineSymbolizer> </Rule> <Rule> &maxscale_zoom12; &minscale_zoom13; <LineSymbolizer> <CssParameter name="stroke">#747b90</CssParameter> <CssParameter name="stroke-width">0.6</CssParameter> </LineSymbolizer> </Rule> </Style> <Style name="contours100"> <Rule> &maxscale_zoom14; &minscale_zoom17; <LineSymbolizer> <CssParameter name="stroke">#9cb197</CssParameter> <CssParameter name="stroke-width">0.7</CssParameter> </LineSymbolizer> </Rule> <Rule> &maxscale_zoom12; &minscale_zoom13; <LineSymbolizer> <CssParameter name="stroke">#747b90</CssParameter> <CssParameter name="stroke-width">0.7</CssParameter> </LineSymbolizer> </Rule> <Rule> &maxscale_zoom10; &minscale_zoom11; <LineSymbolizer> <CssParameter name="stroke">#855d62</CssParameter> <CssParameter name="stroke-width">0.7</CssParameter> </LineSymbolizer> </Rule> </Style> <Style name="contours-text50"> <Rule> &maxscale_zoom14; &minscale_zoom17; <TextSymbolizer name="height" face_name="DejaVu Sans Book" size="8" fill="#747b90" halo_radius="1" placement="line" /> </Rule> </Style> <Style name="contours-text100"> <Rule> &maxscale_zoom14; &minscale_zoom17; <TextSymbolizer name="height" face_name="DejaVu Sans Book" size="8" fill="#747b90" halo_radius="1" placement="line" /> </Rule> <Rule> &maxscale_zoom12; &minscale_zoom13; <TextSymbolizer name="height" face_name="DejaVu Sans Book" size="8" fill="#855d62" halo_radius="1" placement="line" /> </Rule> </Style> <Layer name="srtm_10" status="on" srs="+proj=latlong +datum=WGS84"> <StyleName>contours10</StyleName> <StyleName>contours-text10</StyleName> <Datasource> <Parameter name="table">(select way,height from contours WHERE height::integer % 10 = 0 AND height::integer % 50 != 0 AND height::integer % 100 != 0) as "contours-10"</Parameter> &datasource-settings; </Datasource> </Layer> <Layer name="srtm_50" status="on" srs="+proj=latlong +datum=WGS84"> <StyleName>contours50</StyleName> <StyleName>contours-text50</StyleName> <Datasource> <Parameter name="table">(select way,height from contours WHERE height::integer % 50 = 0 AND height::integer % 100 != 0) as "contours-50"</Parameter> &datasource-settings; </Datasource> </Layer> <Layer name="srtm_100" status="on" srs="+proj=latlong +datum=WGS84"> <StyleName>contours100</StyleName> <StyleName>contours-text100</StyleName> <Datasource> <Parameter name="table">(select way,height from contours WHERE height::integer % 100 = 0) as "contours-100"</Parameter> &datasource-settings; </Datasource> </Layer>
Hillshading
Serve Tiles
Tiles can simply be served by Apache:
vim /etc/apache2/sites-available/mysite <VirtualHost *:80> ServerName mysite.org Alias /tiles /var/www/tiles <LocationMatch "/tiles/"> Order Allow,Deny Allow from all </LocationMatch> </VirtualHost> apache2ctl restart
WMS
In order to serve the OSM data via WMS then can use mod_mapnik_wms:
- http://wiki.openstreetmap.org/wiki/Mod_mapnik_wms
gpg --gen-key apt-get install pbuilder debsigs apache2-prefork-dev libmapnik-dev libgd2-xpm-dev svn export http://svn.openstreetmap.org/applications/utils/mod_mapnik_wms cd mod_mapnik_wms sh autogen.sh vim debian/mapnik_wms.load LoadFile /usr/lib/libmapnik.so.0.7 debuild
This data can then be converted by GeoServer into a KML SuperOverlay to display in Google Earth:
- http://geoserver.org/display/GEOS/GSIP+47+-+WMS+cascading
- http://docs.geoserver.org/stable/en/user/googleearth/tutorials/superoverlaysgwc.html
Rails Port
This is needed to allow editing of the data using Potlatch, JOSM, etc
apt-get install imagemagick libmagick9-dev apt-get install ruby ruby1.8-dev libxml2-dev libxml-ruby1.8 libxml-parser-ruby1.8 rubygems librmagick-ruby gem install -v=2.3.8 rails #gem install libxml-ruby #gem install composite_primary_keys #gem install rmagick gem install timecop gem install pg gem install oauth #svn co http://railsexpress.de/svn/plugins/sql_session_store/trunk sql_session_store apt-get install postgresql-contrib libpq-dev su postgres createuser openstreetmap -s -P createdb -E UTF8 -O openstreetmap openstreetmap createdb -E UTF8 -O openstreetmap osm_test createdb -E UTF8 -O openstreetmap osm psql -d openstreetmap < /usr/share/postgresql/8.4/contrib/btree_gist.sql apt-get install git cd /home git clone git://git.openstreetmap.org/rails.git cd rails cp config/postgres.example.database.yml config/database.yml vim config/database.yml rake gems:install rake db:migrate env RAILS_ENV=production rake db:migrate rake test osmosis --read-xml-0.6 file="planet.osm.bz2" --write-apidb-0.6 populateCurrentTables=yes host="localhost" database="openstreetmap" user="openstreetmap" password="openstreetmap" validateSchemaVersion=no select setval('acls_id_seq', (select max(id) from acls)); select setval('changesets_id_seq', (select max(id) from changesets)); select setval('countries_id_seq', (select max(id) from countries)); select setval('current_nodes_id_seq', (select max(id) from current_nodes)); select setval('current_relations_id_seq', (select max(id) from current_relations)); select setval('current_ways_id_seq', (select max(id) from current_ways)); select setval('diary_comments_id_seq', (select max(id) from diary_comments)); select setval('diary_entries_id_seq', (select max(id) from diary_entries)); select setval('friends_id_seq', (select max(id) from friends)); select setval('gpx_file_tags_id_seq', (select max(id) from gpx_file_tags)); select setval('gpx_files_id_seq', (select max(id) from gpx_files)); select setval('messages_id_seq', (select max(id) from messages)); select setval('sessions_id_seq', (select max(id) from sessions)); select setval('user_tokens_id_seq', (select max(id) from user_tokens)); select setval('users_id_seq', (select max(id) from users)); cd /home/rails ruby script/server cd db/functions make libpgosm.so * Log into PgSQL and execute the CREATE FUNCTION statement from maptile.c's comment: CREATE FUNCTION maptile_for_point(int8, int8, int4) RETURNS int4 AS '/path/to/rails-port/db/functions/libpgosm', 'maptile_for_point' LANGUAGE C STRICT; CREATE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '/path/to/rails-port/db/functions/libpgosm', 'tile_for_point' LANGUAGE C STRICT;
Printing
For Printing TMS layers, need to compile the Trunk version of the MapFish Print Module & then serve the resultant .war with Tomcat:
- Ensure that
JAVA_HOME
points to a JDK. - Download & build source:
svn checkout http://www.mapfish.org/svn/mapfish/print/trunk/ cd trunk ./gradlew build
- Configure Tomcat
vim /etc/tomcat6/policy.d/04webapps.policy permission java.io.FilePermission "/var/lib/tomcat6/webapps/print-servlet-1.2-SNAPSHOT/WEB-INF/classes/logging.properties", "read"; /etc/init.d/tomcat6 restart vim /etc/apache2/sites-available/print ln -s /etc/apache2/sites-available/print /etc/apache2/sites-enabled/print /etc/init.d/apache2 restart
- Copy the WAR file to your %WEBAPPS% directory:
cp trunk/build/libs/print-servlet-1.2-SNAPSHOT.war /var/lib/tomcat6/webapps
- (re)Start Tomcat
- Configure the Map URL for Eden to:
- Configure %WEBAPPS%\print-servlet-1.2-SNAPSHOT\config.yaml: http://www.mapfish.org/doc/print/configuration.html
Printing can also be done within GeoServer:
The 2.0.x versiondidn't support TMS layers, like OpenStreetMap. @ToDo: Test this latest version.
wget http://gridlock.opengeo.org/geoserver/2.1.x/community-latest/geoserver-2.1-SNAPSHOT-printing-plugin.zip cd /var/lib/tomcat6/webapps/geoserver/WEB-INF/lib unzip ~/geoserver-2.1-SNAPSHOT-printing-plugin.zip /etc/init.d/tomcat6 restart #wget http://geoserver.org/download/attachments/20938936/printing-data-2.0.x.zip #cd /usr/local/geoserver-2.0.2/data_dir #unzip ~/printing-data-2.0.x.zip #/usr/local/geoserver/bin/shutdown.sh #/usr/local/geoserver/bin/startup.sh &
- Configure by editing
/var/gis/geoserver_data_dir/printing/config.yaml
according to Documentation
Print to Image
Proxy / Cache
A Proxy can cache remote servers &/or do Reprojection or Combination of Layers
If just wanting to cache the WMS served by GeoServer, then it's probably best to use the integrated GeoWebCache:
Alternatives:
- http://mapproxy.org
- http://mapproxy.org/docs/1.4.0/install.html
adduser --system --disabled-password mapproxy apt-get install -y libgeos-dev libgdal-dev wget http://pypi.python.org/packages/source/M/MapProxy/MapProxy-1.4.0.tar.gz tar zxvf MapProxy-1.4.0.tar.gz cd MapProxy-1.4.0 python setup.py install cd .. cd /home mapproxy-util create -t base-config mapproxy cd mapproxy mapproxy-util create -t wsgi-app -f mapproxy.yaml config.py
- Test: http://localhost:8080/demo/
- WSGI configuration
- Cleaning or Seeding:
mapproxy-seed -s seed.yaml -f mapproxy.yaml
- http://mapproxy.org/docs/1.4.0/install.html
NB This can reveal issues such as the max-width limitation on ArcGIS when converting 4326 to 900913:
- ArcGIS-side fix
- Request a Mercator if you can (3857, 102100 or 102113)
Apache
vim /etc/apache2/sites-available/proxy <VirtualHost *:80> ServerName proxy.sahanafoundation.org ServerAdmin webmaster@sahanafoundation.org WSGIScriptAlias / /home/mapproxy/etc/config.wsgi WSGIDaemonProcess mapproxy user=www-data group=www-data home=/home/mapproxy processes=2 maximum-requests=100 <Location "/"> Order deny,allow Allow from all WSGIProcessGroup mapproxy </Location> ErrorLog /var/log/apache2/proxy_error.log LogLevel warn CustomLog /var/log/apache2/proxy_access.log combined </VirtualHost> mkdir -p /home/mapproxy/var chown www-data /home/mapproxy/var a2ensite proxy /etc/init.d/apache2 force-reload
Cherokee/uWSGI
vim /home/mapproxy/uwsgi.xml <uwsgi> <pythonpath>/home/mapproxy/</pythonpath> <app mountpoint="/"> <script>config</script> </app> <workers>4</workers> </uwsgi> vim /usr/local/etc/cherokee/cherokee.conf vserver!30!rule!300!encoder!deflate = allow vserver!30!rule!300!encoder!gzip = allow vserver!30!rule!300!handler = uwsgi vserver!30!rule!300!handler!balancer = round_robin vserver!30!rule!300!handler!balancer!source!10 = 2 vserver!30!rule!300!handler!check_file = 0 vserver!30!rule!300!handler!error_handler = 1 vserver!30!rule!300!handler!pass_req_headers = 1 vserver!30!rule!300!handler!xsendfile = 0 vserver!30!rule!300!match = directory vserver!30!rule!300!match!directory = /proxy source!2!env_inherited = 1 source!2!group = mapproxy source!2!host = 127.0.0.1:59026 source!2!interpreter = /usr/local/bin/uwsgi -s 127.0.0.1:59026 -x /home/mapproxy/uwsgi.xml source!2!nick = uWSGI 2 source!2!timeout = 300 source!2!type = interpreter source!2!user = mapproxy
- http://mapproxy.org/docs/1.4.0/configuration.html
- http://lists.osgeo.org/pipermail/mapproxy/2010-December/000301.html
vim /usr/share/proj/epsg # Google Maps Global Mercator <900913> +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over
Configuration for TRMM
TRMM Rainfall Monitoring
- http://mapproxy.org/docs/1.4.0/configuration_examples.html
vim /home/mapproxy/etc/mapproxy.yaml layers: - name: TRMM_3B42_V6_DAILY title: Rainfall (1 day) sources: [TRMM_3B42_V6_DAILY_cache, TRMM_3B42_V6_DAILY] - name: TRMM_3B42_V6_10_DAY title: Rainfall (10 days) sources: [TRMM_3B42_V6_10_DAY_cache, TRMM_3B42_V6_10_DAY] caches: TRMM_3B42_V6_DAILY_cache: grids: [GLOBAL_MERCATOR, global_geodetic_sqrt2] sources: [TRMM_3B42_V6_DAILY] TRMM_3B42_V6_10_DAY_cache: grids: [GLOBAL_MERCATOR, global_geodetic_sqrt2] sources: [TRMM_3B42_V6_10_DAY] sources: TRMM_3B42_V6_DAILY: type: wms supported_srs: ['EPSG:4326'] req: url: http://gdata2.sci.gsfc.nasa.gov/daac-bin/wms_trmm? layers: TRMM_3B42_V6_DAILY transparent: true TRMM_3B42_V6_10_DAY: type: wms supported_srs: ['EPSG:4326'] req: url: http://gdata2.sci.gsfc.nasa.gov/daac-bin/wms_trmm? layers: TRMM_3B42_V6_10_DAY transparent: true
Attachments (2)
- osm2pgsql_centroid.patch (18.3 KB ) - added by 14 years ago.
-
imageio-ext-1.0.5-linux64-base-lib.tar.gz
(1.8 MB
) - added by 14 years ago.
GDAL support for JAI (since download site no longer available)
Download all attachments as: .zip