MapServer is written in C++ as a CGI to a web server which handles the HTTP communications with the map server client and is among the fastest, if not the fastest map server available. The name can be confusing because "MapServer" is a GIS map server. There are other map servers available but MapServer has the advantage of maturity and compatibility with data released by NASA. The NASA WorldWind group will furnish you with "Blue Marble", VIIRS satellite imagery and various resolutions of elevation data for a fee, preconfigured for use with MapServer 6.x.
MapServer was initially developed by the University of Minnesota in the mid 1990's but is now developed a steering committee of the Open Source Geospatial Foundation (OSGeo) group.
The easiest installation is from existing, pre-built binary pakages. There are a lot of dependancies which are required for installation as the warping of projections, GIS calculations, image manipulation, etc are all handled by existing libraries. Since MapServer is a web server CGI, the Apache HTTP server is also required.
Dependancies:
- GDAL: gdal-1.9.2-4.el6
(GDAL dependencies)- armadillo: C++ matrix library
- geos: GEOS (Geometry Engine - Open Source) is a C++ port of the JTS Topology Suite (JTS) (eg SQL spatial operators)
- gpsbabel: conversions between various formats used by GPS devices
- grass: used for geospatial data management and analysis, image processing, graphics/map production, spatial modeling, and visualization
- libgeotiff: library for georeferenced raster imagery
- libspatialite: spatial extension to SQLite, providing vector geodatabase functionality
- libtiff4: libraries used for reading and writing TIFF files
- mesa: open source software implementation of OpenGL
- postgis (default has the dependancy compiled in): POstgreSQL GIS extensions
- proj: Cartographic Projections and Coordinate Transformations Library
- proj-epsg: EPSG codes are numeric codes associated with coordinate system definitions. For instance, EPSG:4326 is geographic WGS84. EPSG codes are published by the OGP Surveying and Positioning Committee
- proj-nad: US and Canadian datum shift grids for PROJ
- proj-static: static libraries
- bitstream-vera-fonts-common
- bitstream-vera-sans-fonts
- cfitsio: routines for reading and writing NASA Flexible Image Transport System (FITS) files
- CharLS: JPEG-LS library for lossless and near-lossless image compression and decompression following the ISO/IEC 14495-1:1999 standard.
- fcgi: Fast Common Gateway Interface (CGI)
- hdf5: portable file format with a data model that can represent very complex data objects and a wide variety of metadata
- xerces-c: validating XML parser
- libldap: LDAP library
- libgta: Generic Tagged Arrays (GTA) file format library for multidimensional array data
- libshp1: C library for handling ESRI Shapefiles
- netcdf: Network Common Data Form data formats that support the creation, access, and sharing of array-oriented scientific data.
- libpng: Portable Network Graphics (PNG) image library
- freetype (V2 or newer)
- libjpeg: C library for reading and writing JPEG image files
- zlib: compression library
- libfribidi: library to support middle east languages (Arabic and Hebrew alphabets)
- blas: Basic Linear Algebra Subprograms
- arpack: subroutines designed to solve large scale eigenvalue problems
- lapack: Linear Algebra PACKage library for numerical linear algebra (linear equations and linear least squares, eigenvalue problems, and singular value decomposition)
- liaec: fast lossless compression
- ogdi: Open Geographic Datastore Interface
Installation Instructions:
- # Ubuntu 20.10
- # Ubuntu 18.04
- # RHEL 6
- # RHEL 7
- # Install From Source
Installation: sudo apt-get install cgi-mapserver mapserver-bin mapserver-doc libmapscript-perl python3-mapscript shapelib libprotobuf-c1
(installs MapServer 7.6.1)
Install fast Apache web server and Fast CGI: sudo apt-get install apache2 apache2-bin apache2-utils libfcgi-bin libapache2-mod-fcgid
Turn on CGI and fast CGI (usually enabled by default): sudo a2enmod cgi fcgid
Test if it can run: /usr/lib/cgi-bin/mapserv -v
MapServer version 7.6.1 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=SVG_SYMBOLS SUPPORTS=RSVG SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS SUPPORTS=POINT_Z_M SUPPORTS=PBF INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
Installation: sudo apt-get install cgi-mapserver mapserver-bin mapserver-doc libmapscript-perl python-mapscript ruby-mapscript
(installs MapServer 7.0.7)
Install fast Apache web server and Fast CGI: sudo apt-get install apache2 apache2-bin apache2-utils libapache2-mod-fcgid
Turn on CGI and fast CGI (usually enabled by default): sudo a2enmod cgi fcgid
Test if it can run: /usr/lib/cgi-bin/mapserv -v
MapServer version 7.0.7 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=SVG_SYMBOLS SUPPORTS=RSVG SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
The MapServer RPM is available from the EPEL repository for RHEL 6.x. Many of the prerequisites are also available from EPEL.
Installation: sudo rpm -ivh mapserver-6.0.3-4_0.el6.x86_64.rpm
Put the CGI into the default Apache web server CGI directory: sudo cp /usr/sbin/mapserv /var/www/cgi-bin/
(May also be found in /usr/libexec/mapserver)
Grant SELinux permissions: chcon -u system_u -r object_r -t httpd_sys_script_exec_t /var/www/cgi-bin/mapserv
Test if it can run: /var/www/cgi-bin/mapserv -v
MapServer version 6.0.3 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=CAIRO SUPPORTS=FREETYPE SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
This shows the components which were built-in to the MapServer CGI and thus what capabilities are supported.
EPEL does not have a MapServer RPM for RHEL/CentOS 7 so we must build one. The map server EPEL does furnish is qgis. By building a fresh RPM, we can take advantage of some updates to the MapServer 6 release, which has some security fixes. See CVE 2017-5522
Building a Mapserver RPM of release 6.06 for RHEL 7.x:
We will build a MapServer 6.0.6 RPM for RHEL 7.x. We will utilize an RPM spec file from the EPEL RPM mapserver-6.0.4-1.el6.src.rpm, edit it and use it to build a RHEL 7 RPM from newer MapServer 6.0.6 source code.
Perform the following steps:- Download the source: http://download.osgeo.org/mapserver/mapserver-6.0.6.tar.gz
There is an error you must fix before using the source code:- tar xzf mapserver-6.0.6.tar.gz
- Edit file: mapserver-6.0.6/Makefile.in and change "-W1" to "-Wl"
- Regenerate the tar file: tar czf mapserver-6.0.6.tar.gz mapserver-6.0.6
- Generate the following directory structure:
$HOME/rpmbuild/SPECS/mapserver.spec BUILDROOT/ RPMS/ SOURCES/ SRPMS/
- Put the source code tar file in the "SOURCES" directory:
cp mapserver-6.0.6.tar.gz ~/rpmbuild/SOURCES/ - Extract the spec file from the old RPM:
rpm2cpio mapserver-6.0.4-1.el6.src.rpm | cpio -iv --to-stdout mapserver.spec > mapserver.spec - Edit ~/rpmbuild/SPECS/mapserver.spec
- Change version to 6.0.6 from 6.0.4.
- Change to build directory: cd ~/rpmbuild/SPECS/
- Build RPM: rpmbuild --target x86_64 -bb mapserver.spec
[Potential Pitfall]: g++: error: unrecognized command line option '-W1,-soname,libmapserver.6.0.6.so'
Error in file: ~/rpmbuild/BUILD/mapserver-6.0.6/Makefile.
Fix the file it is generated from as noted above: mapserver-6.0.6/Makefile.in - This generates the following RPMS:
~/rpmbuild/RPMS/x86_64/mapserver-6.0.6-1.el7.centos.x86_64.rpm ~/rpmbuild/RPMS/x86_64/php-mapserver-6.0.6-1.el7.centos.x86_64.rpm ~/rpmbuild/RPMS/x86_64/mapserver-perl-6.0.6-1.el7.centos.x86_64.rpm ~/rpmbuild/RPMS/x86_64/mapserver-python-6.0.6-1.el7.centos.x86_64.rpm ~/rpmbuild/RPMS/x86_64/mapserver-java-6.0.6-1.el7.centos.x86_64.rpm ~/rpmbuild/RPMS/x86_64/mapserver-debuginfo-6.0.6-1.el7.centos.x86_64.rpm
[Potential Pitfall]: configure: error: cannot find gif headers in system path
Solution: sudo yum install giflib-devel
Install:
- sudo rpm -ivh mapserver-6.0.6-1.el7.centos.x86_64.rpm
- sudo rpm -ivh mapserver-perl-6.0.6-1.el7.centos.x86_64.rpm
- sudo rpm -ivh mapserver-python-6.0.6-1.el7.centos.x86_64.rpm
- sudo cp /usr/libexec/mapserver /var/www/cgi-bin/mapserv
Grant SELinux permissions: chcon -u system_u -r object_r -t httpd_sys_script_exec_t /var/www/cgi-bin/mapserv
Download http://download.osgeo.org/mapserver/mapserver-6.0.6.tar.gz
Build:
- tar xzf mapserver-6.0.6.tar.gz
- cd mapserver-6.0.6
- ./configure --prefix=/opt/mapserver
- ./configure --prefix=/opt/mapserver --with-gd=/usr --with-freetype=/usr --with-libiconv=/usr --with-fribidi-config=yes --with-png=/usr --with-jpeg=/usr --with-libiconv=/usr --with-proj=/usr --with-agg-svg-symbols=yes --with-cairo=yes --with-freetype=/usr --with-geos=/usr/bin/geos-config --with-ogr=/usr/bin/gdal-config --with-gdal=/usr/bin/gdal-config --with-wfs --with-wcs --with-wmsclient --with-wfsclient --with-sos --with-threads --with-fastcgi=/usr --with-xml2-config=/usr/bin/xml2-config
- make
- make install
[Potential Pitfall]: configure: error: cannot find gif headers in system path
Solution: sudo yum install giflib-devel
[Potential Pitfall]: configure: error: Could not find gd.h or libgd.a/libgd.so in /usr/local. Make sure GD 2.0.28 or higher is compiled before calling configure.
Solution:
- Check version: rpm -q gd
- or install gd: sudo yum install gd gd-devel
[Potential Pitfall]: configure: error: "Could not find proj_api.h or libproj.a/libproj.so in /usr."
Solution: sudo yum install proj-devel
[Potential Pitfall]: configure: error: OGC WFS Server support cannot be enabled: missing OGR which is required).
Solution: Add the following: --with-ogr=/usr/bin/gdal-config
[Potential Pitfall]: configure: error: couldn't find xml2-config, try using --with-xml2-config=PATH
Solution:
- Install: sudo yum install libxml2-devel
- add: --with-xml2-config=/usr/bin/xml2-config
MapServer is a web server CGI and thus needs to be configured to work with the web server.
Apache HTTPd configuration file: /etc/apache2/sites-available/MapServer.conf
<Directory /data> Options Indexes FollowSymLinks AllowOverride AuthConfig Order allow,deny Allow from all </Directory> Alias /wms /usr/lib/cgi-bin/mapserv <location /wms> setHandler cgi-script Options +ExecCGI -MultiViews +FollowSymLinks AddHandler fcgid-script .fcgi Require all granted SetEnv MS_MAPFILE /data/config/map/nasaww.map </location>
This assumes that the directory for the map and elevation data is /data/ (chosen to match the NASA installation of preconfigured data).
Enable the Mapserver Apache configuration: sudo a2ensite MapServer
Use the command a2dissite to disable use.
Restart the web server: sudo systemctl reload apache2
Verify operating status: systemctl status apache2.service
Apache HTTPd configuration file: /etc/httpd/conf.d/MapServer.conf
<Directory /data> Options Indexes FollowSymLinks AllowOverride AuthConfig Order allow,deny Allow from all </Directory> Alias /wms /var/www/cgi-bin/mapserv <location /wms> setHandler cgi-script Options ExecCGI FollowSymLinks # Turns on CORS to allow other domains to make map tile requests - RHEL7 option, NOT for RHEL6 Header set Access-Control-Allow-Origin "*" SetEnv MS_MAPFILE /data/config/map/nasaww.map </location>
This assumes that the directory for the map and elevation data is /data/ (chosen to match the NASA installation of preconfigured data).
Add SELinux permissions: chcon -u system_u -r object_r -t httpd_config_t /etc/httpd/conf.d/MapServer.conf
Restart the web server: sudo service httpd restart
This root MapServer configuration file is referenced by the Apache HTTPd config file /etc/httpd/conf.d/MapServer.conf. From this ".map" file, other configuration files and data files are referenced.
File: /data/config/map/nasaww.mapMAP NAME "nasaww" STATUS ON SIZE 800 600 #SYMBOLSET "../etc/symbols.txt" EXTENT -180 -90 180 90 UNITS DD SHAPEPATH "../data" IMAGECOLOR 255 255 255 #FONTSET "../etc/fonts.txt" #DEBUG 5 #CONFIG "MS_ERRORFILE" "/tmp/ms_error.txt" WEB IMAGEPATH "/tmp/ms_tmp/" IMAGEURL "/ms_tmp/" METADATA "ows_title" "WorldWind WMS Service" "ows_abstract" "WorldWind WMS Service that contains the following data: ..." "ows_onlineresource" "http://localhost/cgi-bin/mapserv?MAP=/data/config/map/nasaww.map" "ows_enable_request" "*" "ows_srs" "EPSG:4326 EPSG:4269 EPSG:3857" "wms_contactperson" "Joe WMS admin" "wms_contactorganization" "Megacorp" "wms_contactPosition" " " "wms_contactelectronicmailaddress" "joe@megacorp.com" END # TEMPLATE "../htdocs/ol-template.html" END #define your output projection PROJECTION "init=epsg:4326" END #define output formats OUTPUTFORMAT NAME "png" DRIVER AGG/PNG MIMETYPE "image/png" IMAGEMODE RGB EXTENSION "png" FORMATOPTION "GAMMA=0.75" END OUTPUTFORMAT NAME "bil" DRIVER "GDAL/EHdr" MIMETYPE "application/bil16" IMAGEMODE INT16 EXTENSION "bil" END OUTPUTFORMAT NAME "GTiff" DRIVER GDAL/GTiff MIMETYPE "image/tiff" IMAGEMODE RGB EXTENSION "tif" END # # Start of layer definitions # # Imagery layers INCLUDE "bluemarble/bm200407.lay" END # Map File
Be sure to create the working directories:
- sudo mkdir /tmp/ms_tmp/
- sudo mkdir /ms_tmp/
File: /data/config/map/bluemarble/bm200407.lay
LAYER PROCESSING "RESAMPLE=BILINEAR" NAME "BlueMarble-200401" METADATA "wms_title" "BlueMarble July 2004" "wms_abstract" "BlueMarble imagery for January 2004" "wms_keywordlist" "LastUpdate= 2013-07-02T16:26:00Z" "wms_opaque" "1" END TYPE RASTER STATUS ON TILEINDEX "/data/imagery/bluemarbletilegtif/bm200407/bm200407-index.shp" TILEITEM "Location" TYPE RASTER #MAXSCALEDENOM 10000000 PROJECTION "init=epsg:4326" END END
Where the data directory has the following data: ls /data/imagery/bluemarbletilegtif/bm200407/
bm200407-index.dbf bm200407-index.prj bm200407-index.qix bm200407-index.shp bm200407-index.shx world.topo.bathy.200407.3x21600x21600.A1.gtif world.topo.bathy.200407.3x21600x21600.A2.gtif world.topo.bathy.200407.3x21600x21600.B1.gtif world.topo.bathy.200407.3x21600x21600.B2.gtif world.topo.bathy.200407.3x21600x21600.C1.gtif world.topo.bathy.200407.3x21600x21600.C2.gtif world.topo.bathy.200407.3x21600x21600.D1.gtif world.topo.bathy.200407.3x21600x21600.D2.gtif
SELinux File Permissions:
Allow the HTTPd server to access the data: chcon -R -h -u system_u -r object_r -t httpd_sys_content_t /data
For Red Hat, CentOS and other Linux distributions which use SELinux.
MapServer expects the map to be split into the eight world quadrants and labeled A1 to D2.
Blue Marble map data can be downloaded from NASA: NASA Blue Marble- wget world.topo.bathy.200407.3x21600x21600.A1.jpg
- wget world.topo.bathy.200407.3x21600x21600.A2.jpg
- wget world.topo.bathy.200407.3x21600x21600.B1.jpg
- wget world.topo.bathy.200407.3x21600x21600.B2.jpg
- wget world.topo.bathy.200407.3x21600x21600.C1.jpg
- wget world.topo.bathy.200407.3x21600x21600.C2.jpg
- wget world.topo.bathy.200407.3x21600x21600.D1.jpg
- wget world.topo.bathy.200407.3x21600x21600.D2.jpg
Verify the download with gimp or other image program.
File naming convention:
Map Grid | |||
---|---|---|---|
A1: -180 90 -90 0 | B1: -90 90 0 0 | C1: 0 90 90 0 | D1: 90 90 180 0 |
A2: -180 0 -90 -90 | B2: -90 0 0 -90 | C2: 0 0 90 -90 | D2: 90 0 180 -90 |
Imagery file conversion and processing:
Perform the following operations on each image file.
- Geolocate each image:
- gdal_translate -a_srs WGS84 -a_ullr -180 90 -90 0 world.topo.bathy.200407.3x21600x21600.A1.jpg world.topo.bathy.200407.3x21600x21600.A1.gtif -co tiled=yes -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=DEFLATE -co PREDICTOR=2
- gdal_translate -a_srs WGS84 -a_ullr -180 0 -90 -90 world.topo.bathy.200407.3x21600x21600.A2.jpg world.topo.bathy.200407.3x21600x21600.A2.gtif -co tiled=yes -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=DEFLATE -co PREDICTOR=2
- gdal_translate -a_srs WGS84 -a_ullr -90 90 0 0 world.topo.bathy.200407.3x21600x21600.B1.jpg world.topo.bathy.200407.3x21600x21600.B1.gtif -co tiled=yes -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=DEFLATE -co PREDICTOR=2
- gdal_translate -a_srs WGS84 -a_ullr -90 0 0 -90 world.topo.bathy.200407.3x21600x21600.B2.jpg world.topo.bathy.200407.3x21600x21600.B2.gtif -co tiled=yes -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=DEFLATE -co PREDICTOR=2
- gdal_translate -a_srs WGS84 -a_ullr 0 90 90 0 world.topo.bathy.200407.3x21600x21600.C1.jpg world.topo.bathy.200407.3x21600x21600.C1.gtif -co tiled=yes -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=DEFLATE -co PREDICTOR=2
- gdal_translate -a_srs WGS84 -a_ullr 0 0 90 -90 world.topo.bathy.200407.3x21600x21600.C2.jpg world.topo.bathy.200407.3x21600x21600.C2.gtif -co tiled=yes -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=DEFLATE -co PREDICTOR=2
- gdal_translate -a_srs WGS84 -a_ullr 90 90 180 0 world.topo.bathy.200407.3x21600x21600.D1.jpg world.topo.bathy.200407.3x21600x21600.D1.gtif -co tiled=yes -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=DEFLATE -co PREDICTOR=2
- gdal_translate -a_srs WGS84 -a_ullr 90 0 180 -90 world.topo.bathy.200407.3x21600x21600.D2.jpg world.topo.bathy.200407.3x21600x21600.D2.gtif -co tiled=yes -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=DEFLATE -co PREDICTOR=2
- GDAL translate Flags:
- -a_srs: set the projection PROJ.4|EPSG:n
- -a_ullr: georeferenced bounds of the output file: upper-left-lon upper-left-lat lower-right-lon lower-right-lat
- -co: Passes a creation option to the output format driver. See format specific documentation for each format.
- Show info: gdalinfo world.topo.bathy.200407.3x21600x21600.A1.gtif
Driver: GTiff/GeoTIFF Files: world.topo.bathy.200407.3x21600x21600.A1.gtif Size is 21600, 21600 Coordinate System is: GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0], UNIT["degree",0.0174532925199433], AUTHORITY["EPSG","4326"]] Origin = (-180.000000000000000,90.000000000000000) Pixel Size = (0.004166666666667,-0.004166666666667) Metadata: AREA_OR_POINT=Area Image Structure Metadata: COMPRESSION=DEFLATE INTERLEAVE=PIXEL Corner Coordinates: Upper Left (-180.0000000, 90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"N) Lower Left (-180.0000000, 0.0000000) (180d 0' 0.00"W, 0d 0' 0.01"N) Upper Right ( -90.0000000, 90.0000000) ( 90d 0' 0.00"W, 90d 0' 0.00"N) Lower Right ( -90.0000000, 0.0000000) ( 90d 0' 0.00"W, 0d 0' 0.01"N) Center (-135.0000000, 45.0000000) (135d 0' 0.00"W, 45d 0' 0.00"N) Band 1 Block=512x512 Type=Byte, ColorInterp=Red Band 2 Block=512x512 Type=Byte, ColorInterp=Green Band 3 Block=512x512 Type=Byte, ColorInterp=Blue
- Adding overviews to each gtif image:
- gdaladdo -r average world.topo.bathy.200407.3x21600x21600.A1.gtif 2 4 8 16 32 64 128 --config PHOTOMETRIC_OVERVIEW YCBCR --config COMPRESS_OVERVIEW JPEG --config JPEG_QUALITY_OVERVIEW 85 --config INTERLEAVE_OVERVIEW PIXEL
- gdaladdo -r average world.topo.bathy.200407.3x21600x21600.A2.gtif 2 4 8 16 32 64 128 --config PHOTOMETRIC_OVERVIEW YCBCR --config COMPRESS_OVERVIEW JPEG --config JPEG_QUALITY_OVERVIEW 85 --config INTERLEAVE_OVERVIEW PIXEL
- gdaladdo -r average world.topo.bathy.200407.3x21600x21600.B1.gtif 2 4 8 16 32 64 128 --config PHOTOMETRIC_OVERVIEW YCBCR --config COMPRESS_OVERVIEW JPEG --config JPEG_QUALITY_OVERVIEW 85 --config INTERLEAVE_OVERVIEW PIXEL
- gdaladdo -r average world.topo.bathy.200407.3x21600x21600.B2.gtif 2 4 8 16 32 64 128 --config PHOTOMETRIC_OVERVIEW YCBCR --config COMPRESS_OVERVIEW JPEG --config JPEG_QUALITY_OVERVIEW 85 --config INTERLEAVE_OVERVIEW PIXEL
- gdaladdo -r average world.topo.bathy.200407.3x21600x21600.C1.gtif 2 4 8 16 32 64 128 --config PHOTOMETRIC_OVERVIEW YCBCR --config COMPRESS_OVERVIEW JPEG --config JPEG_QUALITY_OVERVIEW 85 --config INTERLEAVE_OVERVIEW PIXEL
- gdaladdo -r average world.topo.bathy.200407.3x21600x21600.C2.gtif 2 4 8 16 32 64 128 --config PHOTOMETRIC_OVERVIEW YCBCR --config COMPRESS_OVERVIEW JPEG --config JPEG_QUALITY_OVERVIEW 85 --config INTERLEAVE_OVERVIEW PIXEL
- gdaladdo -r average world.topo.bathy.200407.3x21600x21600.D1.gtif 2 4 8 16 32 64 128 --config PHOTOMETRIC_OVERVIEW YCBCR --config COMPRESS_OVERVIEW JPEG --config JPEG_QUALITY_OVERVIEW 85 --config INTERLEAVE_OVERVIEW PIXEL
- gdaladdo -r average world.topo.bathy.200407.3x21600x21600.D2.gtif 2 4 8 16 32 64 128 --config PHOTOMETRIC_OVERVIEW YCBCR --config COMPRESS_OVERVIEW JPEG --config JPEG_QUALITY_OVERVIEW 85 --config INTERLEAVE_OVERVIEW PIXEL
- -r: Resampling algorithm nearest|average|gauss|cubic|cubicspline|lanczos|average_mp|average_magphase|mode
- Set the photometric interpretation: --config PHOTOMETRIC_OVERVIEW RGB|YCBCR
- Set the interleaving: --config INTERLEAVE_OVERVIEW PIXEL|BAND
- list of integral overview levels to build: 2 4 8 16 32 64 128
2: overview level that is 1/2 the resolution (in each dimension)
- Generate the index:
- cd /data/imagery/bluemarbletilegtif/bm200407/
- gdaltindex bm200407-index.shp /data/imagery/bluemarbletilegtif/bm200407/*.gtif
This command generates the following files: bm200407-index.dbf, bm200407-index.prj, bm200407-index.shp, bm200407-index.shx[Potential Pitfall]: browser test fails because it can not access the gtif file.
Error: msDrawMap(): Image handling error. Failed to draw layer named 'BlueMarble-200407'. msDrawRasterLayerLow(): Unable to access file. Corrupt, empty or missing file
One must use the fully qualified path name or else MapServer will not be able to find the image file.[Potential Pitfall]: It appears no georeferencing is available for 'world.topo.bathy.200407.3x21600x21600.A1.gtif', skipping.
Use gdalinfo to see if geolocation data has been applied to the image. - shptree bm200407-index.shp
This command generates the quadtree-based spatial index file bm200407-index.qix - Validate: ogrinfo -al -fields=yes bm200407-index.shp
The images are now ready for use by MapServer!
The first test should be to see if the server can list its capabilities:
- http://localhost/wms?service=wms&version=1.3.0&request=GetCapabilities - test localhost
- https://worldwind25.arc.nasa.gov/wms?service=wms&version=1.3.0&request=GetCapabilities - NASA server example
- Command lien without the web server: /usr/lib/cgi-bin/mapserv -nh "QUERY_STRING=map=/data/config/map/nasaww.map&service=wms&version=1.3.0&request=GetCapabilities"
Map Imagery Request:
The bounding box for the request is expressed as the South-West corner and the North-East corner.
Example:
- http://localhost/wms?service=wms&version=1.3.0&CRS=CRS:84&REQUEST=GetMap&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-11.4775,50.53,3.29,58.77-&WIDTH=600&HEIGHT=600&LAYERS=BlueMarble-200407&STYLE=raster - test localhost
- https://worldwind25.arc.nasa.gov/wms?service=wms&version=1.3.0&CRS=CRS:84&REQUEST=GetMap&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-11.4775,50.53,3.29,58.77-&WIDTH=600&HEIGHT=600&LAYERS=BlueMarble-200407&STYLE=raster
- VERSION=version: Request version of WMS standard used in the request
- REQUEST=GetMap: Request for mapping information
- LAYERS=layer_list: Comma-separated list of one or more map layers
- STYLES=style_list: Comma-separated list of one rendering style per requested layer
- CRS=CRS:identifier: Coordinate Reference System, in this case CRS 84 (WGS84) specifying longitude-latitude and the equivalent projection to EPSG:4326
- SRS=namespace:identifier: Spatial Reference System, in this case EPSG:4326, a simple equirectangular projection defined by the European Petroleum Survey Group
- BBOX: Bounding Box - minx,miny,maxx,maxy: Bounding box corners (lower left, upper right) in SRS units
degrees: most Western Longitude, most Southern Latitude, most Eastern Longitude, most Northern Latitude
[Potential Pitfall]: the typical GIS ordering of lat/lon used in discussions and presentations does not hold true here as it is defined by CRS:84, its lon/lat! - WIDTH=output_width: Width in pixels of map picture
- HEIGHT=output_height: Height in pixels of map picture
- FORMAT=output_format: Output raster image format of map
Map of England and Ireland as defined by BBOX coordinates:
- Open Geospatial Consortium (OGC)
- Geospatial Data Abstraction Library (GDAL)
- Office of Geomatics (NGA)
- U.S. Geological Survey (USGS)
"GIS Fundamentals: A First Text on Geographic Information Systems"
by Paul Bolstad ISBN # 1506695876, XanEdu Publishing Inc; 5th edition
|
|