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

Paul Van Deusen Paul_VanDeusen at uml.edu
Fri Apr 6 13:34:32 EDT 2007


>
> 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

Jan,

I always like simple solutions.  I put your code into a bash script and tried it
on a 10240x5120 section of a tif file.  I applied imagemagick to the full file using
convert nlcd.tif -crop 256x256 tiles%d.tif

Imagemagick was done in a couple of seconds, but the shell script took several 
minutes.  Imagemagick wins (I think) because it does everything in memory, whereas
the shell script keeps reloading the full image on each iteration.  However,
imagemagick starts to fall apart on very large files.   gdalsplit might work better.

Still your solution was worth looking at.

Paul




More information about the Gdal-dev mailing list