Setting up TMS

From OpenStreetMap Wiki
Jump to: navigation, search

WMS

You can set up a full WMS (Web Map Service) server to supply backdrop images to JOSM or Merkaartor. It is flexible and "does the right thing", but is a wee bit harder to set up.

TMS

You can set up a TMS (Tile Mapping Service) server to supply backdrop images to Merkaartor. This is a lot easier than setting up a full WMS, both in prep time and server load, but results are only really good for visual use. (The Google Mercator-on-a-sphere projection is not appropriate for "real" cartographic purposes) Think quick & dirty.

OSM's Slippy Tiles diverge from the above TMS spec in that its tiles start counting 0,0 from the top left, not the bottom left as the spec specs. (presumably someone started out by copying Google's tiles, which start 0,0 from the top-left)
Apparently Merkaartor 0.16 will ship with a tickbox in the TMS server setup dialog which allows you to reverse the tile order.
Some explanation of the options and coding details can be found in the gdal2tiles.py source code.

Setting up the TMS

Install GDAL 1.6.0 or newer, including the python-gdal package on Debian/Ubuntu. Make sure gdal2tiles.py is present.

Create or download your GeoTIFF or GDAL-compatible & georegistered map.

If you want to tile multiple images, you might merge them first. A nice space-saving way is to use the gdal_vrtmerge.py example script to make a GDAL virtual raster which can then be fed to the main gdal2tiles.py program.

gdal_vrtmerge.py -o mosaic.vrt -i *.tif


In this case we will generate smoothed ('--resampling=average') maps for zoom scales 11-15 which is about right for this 1:50,000 scale map. Map is reprojected from its native projection on-the-fly (by gdalwarp).

MAP="CI04_GeoTif_1-00.tif"
gdal2tiles.py --profile=mercator --zoom=11-15 --title="NZTopo50" --copyright="Crown" "$MAP"

See "gdal2tiles.py --help" for details.

for OUTFILE in `find | grep '\.png$'` ; do
    # check if image is empty
    CNT=`gdalinfo -mm -noct -nomd "${OUTFILE}" | grep 'Min/Max' | \
       cut -f2 -d= | head -n 3 | tr ',' '\n' | uniq | wc -l`
    if [ "$CNT" -eq 1 ] ; then
       echo "Skipping blank image ..."
       \rm "${OUTFILE}"
       continue
    fi
done


For the example above:
Name
NZTopo50
Server address
localhost
Path
maps/CI04_GeoTif_1-00/%1/%2/%3.png
Tile size
256
Minimum zoom
11
Maximum zoom
15
Origin is bottom-left
"x"
Personal tools
Namespaces
Variants
Actions
site
Toolbox