[Gdal-dev] create 256x256 tiles for google maps

Stephen Woodbridge woodbri at swoodbridge.com
Sat Apr 7 11:43:59 EDT 2007


Hi Jan,

Great script, thank you for sharing it.

You mentioned working with projected coordinates below. I would like to 
do something along the lines gdalsplit, but be able to define the height 
and width on projected coordinates, like 0.0625 degrees and have it 
split the src image into tiles that size but the edges aligned to hit 
1.0 degree intervals. So like 42.0, 42.0625, 42.125, ...

Is there an easy way to do this in a script?
Would it be easy to modify gdalsplit to do something like this?
What if the src image is in some UTM projection and you want the tiles 
in geographic projection?

Inquiring minds want to know :)

-Steve W

Jan Hartmann wrote:
> 
> 
> Markus Neteler wrote:
>> On Thu, Apr 05, 2007 at 09:43:57PM +0200, Mateusz Loskot wrote:
>>> Paul Van Deusen napisa?(a):
>>>> I am using imagemagick to crop a geotiff file into 256x256 gif files to
>>>> serve as tiles for google maps.
>>>> However, it starts to choke once the tiff file gets larger than  1/2
>>>> GB.   Can gdal_translate take
>>>> a tif file and split it into individual tile files of a specific size?
>>> Paul,
>>>
>>> AFAIK, GDAL won't help here out of the box.
>>> Users usually take gdal_translate.cpp program and customize it to do 
>>> this
>>> job.
>>> Here you can find such utility called gdalsplit and posted to the list a
>>> longer while ago:
>>>
>>> http://lists.maptools.org/pipermail/gdal-dev/2004-September/004135.html
>>>
>>> May be it will work for you.
>>
>> If anyone happens to haave an updated version of "gdalsplit"
>> I would be interested.
>> Maybe some mechanism to manage user contributions would be
>> good (like the GRASS Addons repository).
>>
>> Markus
>>
>> ------------------
>> ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
>> ITC -> since 1 March 2007 Fondazione Bruno Kessler
>> ------------------
>> _______________________________________________
>> Gdal-dev mailing list
>> Gdal-dev at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/gdal-dev
>>
> 
> Perhaps I am overlooking something, or didn't understand the question 
> right, but I regularly create tiles from a large tif-file with the 
> -srcwin <xoff yoff xsize ysize> parameter of gdal_translate. A simple 
> bash-script to tile in.tif (30000*30000 pixels) into 256*256 tiles would 
> be:
> 
> width=30000
> height=30000
> y=0
> while [ $y -lt $height ]
> do
>   x=0
>   while [ $x -lt $width ]
>   do
>      outtif=t_${y}_$x.tif
>      gdal_translate -srcwin $x $y 256 256 in.tif $outtif
>      let x=$x+256
>   done
>   let y=$y+256
> done
> 
> This would result in about 14000 files. This is so simple that it can 
> even be done with a primitive DOS batch file.
> 
> Most of the time I work with projected coordinates (-projwin instead of 
> -srcwin) but the idea is the same. Note by the way that -projwin uses 
> the *upper* left corner as reference.
> 
> Jan
> 
> Dr. J. Hartmann
> Department of Geography
> University of Amsterdam
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev




More information about the Gdal-dev mailing list