wiki:UserDocs/Gdal2Tiles

GDAL2Tiles Utility

Manual page for gdal2tiles.py

NOTE: This manual page should be available soon on http://www.gdal.org/gdal2tiles.html

generates directory with TMS tiles, KMLs and simple web viewers

Usage:

gdal2tiles.py [-title "Title"] [-publishurl http://yourserver/dir/]
              [-nogooglemaps] [-noopenlayers] [-nokml]
              [-googlemapskey KEY] [-forcekml] [-v]
              input_file [output_dir]

This utility generates a directory with small tiles and metadata, following OSGeo Tile Map Service Specification. Simple webpages with viewers based on Google Maps and OpenLayers? are generated as well - so anybody can comfortably explore your maps on-line and you do not need to install or configure any special software (like mapserver) and the map displays very fast in the webbrowser. You only need to upload generated directory into a webserver.

GDAL2Tiles creates also necessary metadata for Google Earth (KML SuperOverlay?), in case the supplied map uses EPSG:4326 projection.

World files and embeded georeference is used during tile generation, but you can publish a picture without proper georeference too.

All parameters are optional, but input_file. If output_dir is not specified then input_file without extension is used.

-title "Title":

Title used for generated metadata, web viewers and KML files.

-publishurl http://yourserver/dir/:

Address of a directory into which you are going to upload the result. It should end with slash.

-nogooglemaps:

Do not generate Google Maps based html page.

-noopenlayers:

Do not generate OpenLayers? based html page.

-nokml:

Do not generate KML files for Google Earth.

-googlemapskey KEY:

Key for your domain generated on Google Maps API webpage (http://www.google.com/apis/maps/signup.html).

-forcekml:

Force generating of KML files. Input file must use EPSG:4326 coordinates!

-v:

Generate verbose output of tile generation.

NOTE: gdal2tiles.py is a Python script, and will only work if GDAL was built with Python support.

Usage tips and FAQ

Creating one KMZ file from generated structure

You need to zip (by zip, pkzip, WinZip?, ...) content of the generated directory the way, that doc.kml is directly available in the root of zip. Then rename .zip to .kmz and whole pyramid structure is available as one huge file. Google Earth should open such file without troubles.

If you need to publish the map online, it is better to upload generated structure directly as it was generated, then tiles are requested separately and users don't need to wait for dowload of the whole map. One huge KMZ is nice for CD-ROM distribution for example.

Why KML generator needs raster files with EPSG:4326 projection?

Google Earth expect raster tiles in this projection. You can use gdalwarp utility from GDAL (or FWTools) to warp your existing rasters into EPSG:4326. If you are sure, that your raster internally use correct coordinates, but gdal2tiles.py does not generate KML files, then use -forcekml parameter.

File with name doc.kml is generated always. It is for local computer usage and for KMZ. If you would like to generate Google Earth KML Superoverlay for distributing online, then specify -publishurl parameter and another kml file (with the file name same like output_dir) is generated. This KML file you can send by email or publicly linked, it should contain correct url for published tiles.

Can I use tiles as overlay on Google Maps?

Not yet. For this functionality TMS global-* profiles need to be implemented. It is on the TODO list (any support is welcome ;-)). If you would like to generate overlays from vector data, then use Mapnik Project

Project web site

GDAL2Tiles - Raster Maps Tile Publishing and KML Generation at http://www.klokan.cz/projects/gdal2tiles/

More info

This utility was created as a project GDAL2Tiles in Google Summer of Code 2007.

Last modified 14 years ago Last modified on Aug 24, 2007, 3:12:33 PM