JA:タイルとタイリング/WMSやTMSのセットアップ

From OpenStreetMap Wiki
(Redirected from JA:Setting up TMS)
Jump to navigation Jump to search

broom

Help (89606) - The Noun Project.svg

WMS

WMS (Web Map Service) サーバをセットアップして、 JOSMMerkaartor に背景画像を供給することができます。これは柔軟で「正しい行い」ですが、セットアップはほんの少し難しいです。

  • MapProxy が利用できます。このウィキの Mappproxy setup も参照してください。
  • GeoTIFF のラスタ地図(または、GDAL で知られている形式)で入力する必要があります
  • MapServer ソフトウェアを実行している必要があります。
  • Apache やその他のウェブサーバを実行している必要があります。
  • GDAL 1.6.0 またはそれ以降の gdal2tiles.py が必要です(MapSlicer が役立つかもしれません)

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.
  • Needs input GeoTIFF raster map (or format known to GDAL).
  • Needs Apache or some other web server running.
  • Needs gdal2tiles.py from GDAL 1.6.0 or newer. (MapSlicer may help)
  • Needs Merkaartor 0.16 or newer to get tile order to match the OSGeo TMS spec. (otherwise it is reversed and in the wrong hemisphere)

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.

  • When it has finished generating the tiles copy the new directory onto your local webserver. View live by going to your web browser and loading up openlayers.html in that directory.
  • If the reprojection rotates the image at all you might end up with empty tiles. Here is a little Bourne shell script to remove them. (n.b. also removes solid greyscale tiles!)
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


  • In Merkaartor setup is in Tools → TMS Servers Editor...
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"
  • [Add]