Configuring Tile Map Services for use in Geoide

From Geoikia-english

Jump to: navigation, search

Image:germanflagthumb.png Deutsch Image:dutchflagthumb.png Nederlands

> Main Page > How can I ...? > Configuring Tile Map Services for use in Geoide


Contents

Introduction

You may configure a Tile Map Service (TMS) for use in Geoide easily by using open source software. You don't need an extra service. The tiles can be delivered by a web server, if they are available in accordance with the TMS standard. Source raster data files can be transformed to a tile set with the open source product GDAL.

The following steps describe how tiles can be made from one or more source data files containing a georeference (i.e. GeoTIFF and ECW).

Backgrounds

> Tile Map Services in Geoide

Workflow

Installation of necessary tools

In Linux environments mostly packages are available in the distribution. On windows systems you can use (among others) GDAL through the OSGeo4W package. This package offers a graphical interface to install a variety of open source GIS tools and libraries.


1. Install OSGeo4W. Choose during installation “advanced” install and select at least the following packages (including dependencies):

  • Commandline utilities: gdal, gdal17, libgeotiff, shell
  • Libraries: gdal17, gdal17-ecw, gdal17-python

2. On a windows system you have to start the OSGeo4W shell and select the right version of the GDAL library using the following command:

gdal17

Extra steps for tiling an ECW

If you want to tile an ECW (Enhanced Compression Wavelet), then you need to follow next installation steps:

1. Download and install the ECW Read Only Library from ERDAS:

http://erdas.com/products/ecw/ERDASECWJPEG2000SDK/Details.aspx
Image:tip.png ERDAS ECW library is not Open Source. However ERDAS offers free dll's under conditions after registration.

2. Go to the right directory matching your windows version (32 or 64 bit)../redist/vc90/win32 or ../win64

3. Copy the *.dll's to the bin directory of your OSGE4W installation (c:\OSGeo4\bin)

Joining Tiles in Virtual Raster

If you want to generate tiles from one source file, then you may skip this step and proceed with Generate tiles from one source file or virtual raster.

If you want to generate tiles from multiple source files then they have to be joined first into a so called virtual raster. In a virtual raster all source files references are combined and the bounding box of each source file is included. Most GDAL tools accept a virtual raster as input, so multiple source files can be digested as one single data set.

Image:tip.png If the source files do not have a georeference, then you may include them in a virtual raster and add a bounding box. This will not be addressed here. You may find more information in the GDAL documentation.

Execute the following command to generate a virtual raster:

gdalbuildvrt out.vrt in1.tiff in2.tiff in3.tiff …

Output is a virtual raster named "out.vrt" in which all listed source files are included.

In a Linux environment you may use wild cards to list source files. This is not possible in Windows however. If you want to include many source files, then the following commands may be used:

dir /b *.tiff > files.txt
gdalbuildvrt -input_file_list files.txt out.vrt

A list of all source files is written to "files.txt" and a virtual raster named "out.vrt" will be generated in which all source files (referred to in files.txt) are included.

Generate tiles from one source file or virtual raster

The tool gdal2tiles is able to generate tles from one source file (this may be a virtual raster). The version of gdal2tiles which comes at the moment with the OSGeo4W package is limited to write tiles in PNG format. Aspart of the MapTiler project a version of gdal2tiles is maintained which can write to JPEG format. This is a python script (gdal2tiles.py) and can be found in the source repository of MapTiler. In next steps it is assumed that this adjusted version of gdal2tiles is used.

Image:tip.png If you want to generate JPEG output then take the following into account: gdal2tiles generates tiles per layer and starts at the lowest level (tiles on this level have unscaled source data). For each tile in a higher level, four tiles from a lower level are read, scaled and joined to a new tile. This method is for PNG files no problem. However using JPEG files, it means that quality loss as a result of compression is accumulating. You may use an alternative version of gdal2tiles.py, which tiles with tile sizes of 512x512 pixels and saves higher quality JPEG files, in order to reduce accumulation of errors. Download gdal2tiles.512.py.

Use the following command to generate tiles from one source file:

python gdal2tiles.py -f png -s EPSG:28992 -p raster out.vrt tiles

Clarification of the arguments:

  • -f png | jpeg: Tiles are written in png format (use "jpeg" to write in JPEG format).
  • -s EPSG:28992: The spatial reference system of the source files (if this information is available in the source file then you do not need this argument).
  • -p raster: The output format is “raster”. This means that the raster data will not be transformed to as standard reference system. Use this argument if tiles have to be available in the original reference system.
  • -e: Proceed after a disrupted operation (already generated tiles will be skipped).
  • out.vrt: Name of source file or virtual raster
  • tiles: The output directory. The tool makes a TMS structure to whoch the tile are written. A metadata file (tilemapresource.xml) is also generated in this directory. Map viewer read this file for information on the number of layers with tiles and the bounding box and origin of tiles. Tiles have a size of 256x256 pixels. This can not be changed.
Personal tools