[gdal-dev] gdal2tiles strangeness

Klokan Petr Přidal klokan at klokan.cz
Fri Apr 3 06:04:20 EDT 2009


Dear Mano,

You are right, gdal2tiles.py in stable GDAL 1.6 has a bug for KML
generation in "-p raster", which is now fixed in gdal-trunk as well as
in maptiler SVN...

Here is it step by step for your process:

- Download the latest gdal2tiles from gdal-trunk or maptiler svn and
save it on your disk:
http://maptiler.googlecode.com/svn/trunk/maptiler/gdal2tiles.py

- Download the "world.200401.3x21600x10800.jpg" (or any other world map):
http://earthobservatory.nasa.gov/Features/BlueMarble/BlueMarble_monthlies.php

- Assign georeference and srs:
gdal_translate -of vrt -a_srs epsg:4326 -a_ullr -180 90 180 -90
world.200401.3x21600x10800.jpg world.vrt

- Create 'raster' tiles (it will automatically generate KML, because
input is epsg:4326):
python ./gdal2tiles.py -p raster world.vrt

Open doc.kml in Google Earth...  ;-)

If you don't want to update the gdal2tiles utility and you need
workflow with stable GDAL 1.6 then use:

gdal2tiles -p geodetic world.vrt

It will generate you correct KML for Google Earth directly and viewer
compatible with OpenLayers base map and other WMS, WMS-C, and TMS
services, but your map will be resampled to one of the fixed map
scales - according the TMS Global Geodetic profile definition:
http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification

Best regards,

Klokan

2009/4/3 Mano Marks <mmarks at google.com>:
> So, using -p "raster" creates far worse distortion in the KML. I'm back to
> not using it. I get distortion only at the highest zoom levels that way.
>
> 2009/4/1 Klokan Petr Přidal <klokan at klokan.cz>
>>
>> Mano,
>>
>> > Thanks for the pointer. So it looks like, right now, there's a bug in
>> > gdal2tiles, according to  Jesse? Any news on when that might be fixed?
>>
>> Just use this gdal2tiles.py:
>> http://maptiler.googlecode.com/svn/trunk/maptiler/gdal2tiles.py
>>
>> The issue he is referring is fixed in MapTiler SVN:
>> http://code.google.com/p/maptiler/issues/detail?id=9
>> Commited in maptiler SVN in r17 on Mar 20, 2009.
>>
>> I am proposing to fix all known bugs during this summer as part of
>> Google Summer of Code project, and also implement support for OGC WMTS
>> standard, publish a stable version of MapTiler
>> (http://www.maptiler.org/) and synchronize the code with GDAL SVN.
>>
>> Klokan
>>
>> >
>> > Mano
>> >
>> > 2009/3/31 Klokan Petr Přidal <klokan at klokan.cz>:
>> >> Mano,
>> >>
>> >> If you would like to have both Google Maps and Google Earth
>> >> presentation for a global map then you must generate two tile sets,
>> >> because Google Maps supports only Mercator tiles (EPSG:900913) and
>> >> Google Earth only geodetic (EPSG:4326).
>> >>
>> >> GDAL2Tiles has as a default tile profile 'mercator', it means that it
>> >> will warp your input into Spherical Mercator internally.
>> >> To create tiles and KML for Google Earth for your EPSG:4326 input data
>> >> you should use -p "raster".
>> >>
>> >> From the "gdal2tiles --help":
>> >>
>> >> -k, --force-kml     Generate KML for Google Earth - default for
>> >> 'geodetic'
>> >>                        profile and 'raster' in EPSG:4326. For a dataset
>> >> with
>> >>                        different projection use with caution!
>> >>
>> >> Detailed description of recommended step by step usage of gdal2tiles
>> >> for global maps was posted by Jesse Varner
>> >> from CIRES & NOAA/NGDC, who used gdal2tiles for official presentation
>> >> of Global magnetic anomaly map EMAG2 (for Google Maps/Earth) at:
>> >> http://ngdc.noaa.gov/geomag/data/Google_Maps/EMAG2/index.html
>> >>
>> >> His post is here:
>> >> http://groups.google.com/group/maptiler/msg/fe105e27a62711e4
>> >>
>> >> Best regards,
>> >>
>> >> Klokan
>> >>
>> >> On Tue, Mar 31, 2009 at 6:37 PM, Mano Marks <mmarks at google.com> wrote:
>> >>> I'm getting started with gdal2tiles, and I'm getting strange results.
>> >>>
>> >>> I downloaded a blue marble jpg from NASA:
>> >>> http://www.nasa.gov/vision/earth/features/blue_marble.html
>> >>>
>> >>> And I ran the following command lines:
>> >>>
>> >>> gdal_translate -of VRT -a_srs EPSG:4326 -gcp 0 0 -180 90 -gcp 21600 0
>> >>> 180 90 -gcp 21600 10800 180 -90 world_200401.jpg bluemarble1.vrt
>> >>>
>> >>> gdalwarp -of VRT -t_srs EPSG:4326 bluemarble1.vrt bluemarble2.vrt
>> >>>
>> >>> gdal2tiles -k bluemarble2.vrt
>> >>>
>> >>> Of course, the last step took awhile.
>> >>>
>> >>> The Google Maps and OpenLayers output was fine. However, the KML had
>> >>> some odd results. When loaded directly, it looked fine, but when I
>> >>> zoomed out, it appeared that what was the equivalent of zoom 0 and 1
>> >>> the images retain a Mercator projection. Is this a known issue, or did
>> >>> I do something wrong?
>> >>>
>> >>> --
>> >>> Mano Marks
>> >>> Geo Developer Advocate
>> >>> Google, Inc.
>> >>> mmarks at google.com
>> >>> http://twitter.com/ManoMarks
>> >>> _______________________________________________
>> >>> gdal-dev mailing list
>> >>> gdal-dev at lists.osgeo.org
>> >>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> http://blog.klokan.cz/
>> >> http://www.maptiler.org/
>> >> http://www.oldmapsonline.org/
>> >>
>> >
>> >
>> >
>> > --
>> > Mano Marks
>> > Geo Developer Advocate
>> > Google, Inc.
>> > mmarks at google.com
>> > http://twitter.com/ManoMarks
>> >
>>
>>
>>
>> --
>> http://blog.klokan.cz/
>> http://www.maptiler.org/
>> http://www.oldmapsonline.org/
>
>
>
> --
> Mano Marks
> Geo Developer Advocate
> http://twitter.com/ManoMarks
> Join me for Google I/O, Google's biggest Developer Conference, in San
> Francisco, May 27th and 28th, 2009
> http://code.google.com/events/io/
>
>
-- 
http://blog.klokan.cz/
http://www.maptiler.org/
http://www.oldmapsonline.org/


More information about the gdal-dev mailing list