RE. : [Gdal-dev] Making tiles automatically?

guillaume huby guillaume.huby.lists at gmail.com
Thu Jan 11 09:11:56 EST 2007


>
> Dear list,
>
> I would like to tile a tiff-image (with tfw file) in 16 tiles.
> I wonder if there is a possibility to avoid manual tiling for every tile like:
>
> gdal_translate –projwin 3429886 5799741 3435890 5794667
> ...path_to\landsat7.tiff path_to\landsat7_tile1.tiff
>
> ...this would be so much typing.
>
> Is there anywhere a possibility to tile the image with a script?
> Does the possibily exist to tile it automatically in the shell?
>
> The tiling process is more simple when thinking in number of pixels
instead of referenced coordinates.
Some kind of pseudo-code for exemple.

# xOff and yOff are the upper left pixel of tile not in referenced
coordinates but in matrix coordinates.
# nPixelsXImage and nPixelsYImage are the dimensions of the full image.
# You can get them parsing the output of gdalinfo for exemple.
# xSize and ySize are the dimensions in number of pixels of the tiles.
# You can compute them using nPixelsXImage and nPixelsYImage and the number
of tiles you expect :
$xSize = $nPixelsXImage / $nTilesX
$ySize = $nPixelsYImage / $nTilesY
for $xOff = 1 to $nPixelsXImage step $xSize
  for $yOff = 1 to $nPixelsYImage step ySize
    call gdal_translate -co "TFW=YES" -srcwin $xOff $yOff $xSize $ySize
input.tif output_$xOff_$yOff.tif
  end for $yOff
end for $xOff

Note that the last line and the last raw of tiles might not have the
expected $xSize $ySize.

Another question: After tiling: Will for every tile a tfw-file be produced?
>
>
For this add  the gdal_translate option -co  "TFW=YES".

I hope this will help you.

Regards,
Guillaume.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20070111/995fe91a/attachment.html


More information about the Gdal-dev mailing list