Version 77 (modified by 14 years ago) ( diff ) | ,
---|
Table of Contents
Installation of GIS Tools on Linux
Suggest these CLI tools for data manipulation:
- GDAL's ogr2ogr, etc
- Convert SRTM to GeoTIFF
PostGIS
PostGIS adds Spatial storage to PostgreSQL
- alternatively these can be installed as part of OpenGeoSuite
NB PostGIS in Debian Lenny is rather old - recommend using the version in Squeeze
apt-get install 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
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');
Java
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
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): 32-bit:
cd /usr/lib/jvm/java-6-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
64-bit:
cd /usr/lib/jvm/java-6-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
Apache Tomcat
Tomcat is the recommended way to deploy Java applications
- Debian:
apt-get install sun-java6-jdk tomcat5.5 libapache2-mod-jk a2enmod jk vim /etc/libapache2-mod-jk/workers.properties workers.java_home=/usr/lib/jvm/java-6-sun # Needed for GeoServer-2.1-beta1 (2.0.2 was fine, but maybe it's because of running both at once?) vim /etc/default/tomcat5.5 JAVA_OPTS="-Djava.awt.headless=true -Xmx256M -XX:MaxPermSize=128m" vim /etc/init.d/tomcat5.5 TOMCAT5_SECURITY=no /etc/init.d/tomcat5.5 restart
Enable access to GeoServer on Port 80:
a2enmod proxy a2enmod proxy_ajp a2enmod proxy_http vim /etc/apache2/mods-enabled/proxy.conf Deny from all Allow from localhost vim /etc/apache2/sites-available/geo <VirtualHost *:80> ServerName geo.eden.sahanafoundation.org ServerAdmin webmaster@sahanafoundation.org DocumentRoot /var/www ProxyPreserveHost on RewriteEngine On # These 2 lines should be disabled in Production RewriteRule ^/geoserver/(.*)$ ajp://localhost:8009/geoserver/$1 [P] ProxyPassReverse /geoserver ajp://localhost:8009/geoserver/ RewriteRule ^/geoserver/wfs ajp://localhost:8009/geoserver/wfs [P] ProxyPassReverse /geoserver/wfs ajp://localhost:8009/geoserver/wfs RewriteRule ^/geoserver/wms ajp://localhost:8009/geoserver/wms/ [P] ProxyPassReverse /geoserver/wms ajp://localhost:8009/geoserver/wms/ RewriteRule ^/geowebcache/(.*)$ ajp://localhost:8009/geowebcache/$1 [P] ProxyPassReverse /geowebcache ajp://localhost:8009/geowebcache/ 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://downloads.sourceforge.net/project/geoserver/GeoServer/2.0.2/geoserver-2.0.2-war.zip cd /var/lib/tomcat5.5/webapps unzip ~/geoserver-2.0.2-war.zip /etc/init.d/tomcat5.5 restart vim /etc/iptables.rules -A INPUT -p tcp --dport 8180 -j ACCEPT reboot
http://geo.host.domain:8180/geoserver
or
wget http://downloads.sourceforge.net/project/geoserver/GeoServer/2.0.2/geoserver-2.0.2-bin.zip cd /usr/local unzip ~/geoserver-2.0.2-bin.zip ln -sf /usr/local/geoserver-2.0.2 /usr/local/geoserver vim /etc/profile GEOSERVER_HOME=/usr/local/geoserver export GEOSERVER_HOME vim /etc/rc.local /usr/local/geoserver/bin/startup.sh & vim /etc/iptables.rules -A INPUT -p tcp --dport 8080 -j ACCEPT reboot
http://geo.host.domain:8080/geoserver
Configure:
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
OpenStreetMap data can be stored in a PostGIS database & rendered using Mapnik.
To support Key/Value pairs:
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/ cd osm2pgsql ./autogen.sh ./configure sed -i 's/-g -O2/-O2 -march=native -fomit-frame-pointer/' Makefile make make install
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
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 --host localhost --user gis --dbname gis --symbols ./symbols/ --world_boundaries ./world_boundaries/ --port 5432 --password mypasswordforgis
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, 18, "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/N18W071.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/N19W071.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/N20W073.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 <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="&osm2pgsql_projection;"> <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="&osm2pgsql_projection;"> <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="&osm2pgsql_projection;"> <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
Another option is to serve via WMS (using an Apache module):
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/tomcat5.5/policy.d/04webapps.policy permission java.io.FilePermission "/var/lib/tomcat5.5/webapps/print-servlet-1.2-SNAPSHOT/WEB-INF/classes/logging.properties", "read"; /etc/init.d/tomcat5.5 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/tomcat5.5/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:
However this version doesn't yet support TMS layers, like OpenStreetMap.
wget http://geoserver.org/download/attachments/20938936/printing-2.0.x.zip wget http://geoserver.org/download/attachments/20938936/printing-data-2.0.x.zip cd /usr/local/geoserver-2.0.2/webapps/geoserver/WEB-INF/lib unzip ~/printing-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
/usr/local/geoserver-2.0.2/data_dir/printing/config.yaml
according to Documentation
Print to Image
Cache
- http://mapproxy.org
- http://mapproxy.org/docs/latest/install.html
wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz tar zxvf Imaging-1.1.7.tar.gz cd Imaging-1.1.7 python setup.py install cd .. wget http://pyproj.googlecode.com/files/pyproj-1.8.6.tar.gz tar zxvf pyproj-1.8.6.tar.gz cd pyproj-1.8.6 python setup.py install cd .. wget http://pyyaml.org/download/pyyaml/PyYAML-3.09.tar.gz tar zxvf PyYAML-3.09.tar.gz cd PyYAML-3.09 python setup.py install cd .. wget http://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.1.1.tar.gz tar zxvf Jinja2-2.1.1.tar.gz cd Jinja2-2.1.1 python setup.py install cd .. wget http://pypi.python.org/packages/source/f/flup/flup-1.0.3.dev-20100525.tar.gz tar zxvf flup-1.0.3.dev-20100525.tar.gz cd flup-1.0.3.dev-20100525 python setup.py install cd .. wget http://pypi.python.org/packages/source/P/Paste/Paste-1.7.4.tar.gz tar zxvf Paste-1.7.4.tar.gz cd Paste-1.7.4 python setup.py install cd .. wget http://pypi.python.org/packages/source/P/PasteDeploy/PasteDeploy-1.3.3.tar.gz tar zxvf PasteDeploy-1.3.3.tar.gz cd PasteDeploy-1.3.3 python setup.py install cd .. wget http://pypi.python.org/packages/source/P/PasteScript/PasteScript-1.7.3.tar.gz tar zxvf PasteScript-1.7.3.tar.gz cd PasteScript-1.7.3 python setup.py install cd .. wget http://pypi.python.org/packages/source/M/MapProxy/MapProxy-0.8.4.tar.gz tar zxvf MapProxy-0.8.4.tar.gz cd MapProxy-0.8.4 python setup.py install cd .. cd /home paster create -t mapproxy_conf mapproxy
- http://code.google.com/p/modwsgi/wiki/IntegrationWithPylons
wget http://pypi.python.org/packages/source/C/ConcurrentLogHandler/ConcurrentLogHandler-0.8.4.tar.gz tar zxvf ConcurrentLogHandler-0.8.4.tar.gz cd ConcurrentLogHandler-0.8.4 python setup.py install cd .. mkdir /var/www/.python-eggs chown www-data /var/www/.python-eggs vim /home/mapproxy/mapproxy.py import os, sys from paste.script.util.logging_config import fileConfig BASEDIR = os.path.dirname(__file__) INIFILE = os.path.join(BASEDIR, 'etc', 'config.ini') LOGFILE = os.path.join(BASEDIR, 'etc', 'log_deploy.ini') sys.path.append(BASEDIR) os.environ['PYTHON_EGG_CACHE'] = '/var/www/.python-eggs' fileConfig( LOGFILE ) from paste.deploy import loadapp application = loadapp('config:%s' % INIFILE) vim /etc/apache2/sites-available/proxy <VirtualHost *:80> ServerName proxy.sahanafoundation.org ServerAdmin webmaster@sahanafoundation.org WSGIScriptAlias / /home/mapproxy/mapproxy.py 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> cd /etc/apache2/sites-enabled ln -s ../sites-available/proxy /etc/init.d/apache2 force-reload
- http://mapproxy.org/docs/latest/configuration.html
- http://mapproxy.org/docs/latest/install.html
- http://geowebcache.org
- e.g. included as part of OpenGeoSuite
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 13 years ago.
GDAL support for JAI (since download site no longer available)
Download all attachments as: .zip