[Gdal-dev] creating tiles from rasters using gdal

Paul Spencer pagameba at gmail.com
Tue May 15 13:04:22 EDT 2007


Hi all ...

I need to turn some rasters (png and tiff) into tiles for use in a  
tiled map application.  For various reasons, these rasters are not  
georeferenced and I don't need them to be.

What I have done is create a shell script with a couple of loops that  
calls gdal_translate to pick out 256x256 tiles and save them into the  
directory structure that I need (Paul Ramsey's TMS structure in this  
case).  Here is the command that I am invoking for each tile:

gdal_translate -quiet -of "PNG" -outsize 256 256 -srcwin $l $t 256  
256 $src ../tiles/1.0.0/"$tileset"/"$scale_number"/"$nCol"/"$y"".png"

where $l and $t are determined from the current row/col * 256, $src  
is the input raster, $tileset and $scale_number are used for  
subdirectories, $nCol is the current column and $y is the inverse of  
the current row (need to adjust between pixel and geographic space  
for the client)

This works perfectly but becomes increasingly slow - I'm processing  
6804 tiles out of a raster that is 21504 x 20736 pixels, the first  
100 or so were fast but now it is down to 3-4 secs per tile (I'm at  
4200 tiles so far).

How can I improve performance?  Is there an existing utility that  
will do something like this or do I need to roll my own version of  
gdal_translate?

Cheers

Paul
+-----------------------------------------------------------------+
|Paul Spencer                          pspencer at dmsolutions.ca    |
+-----------------------------------------------------------------+
|Chief Technology Officer                                         |
|DM Solutions Group Inc                http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+








More information about the Gdal-dev mailing list