[Gdal-dev] How to read GeoTIFF dimensions?

Jonah Duckles jonahd at gmail.com
Mon Mar 2 09:34:55 EST 2009


>
> - Let GDAL automatically cut each image into 4 parts without giving XY
> coordinates?
>

Your question really has nothing to do with GDAL and is more about shell
programming and shell usage.  GDAL gives you all the information, what you
do with it is up to you.  The DOS/Windows shell is not optimized for this
kind of scripting.  Running the gdal tools under cygwin might work best for
you as many examples exist of this type of thing in bash.

Looks like you're on windows, but if you have sed and grep installed in your
path you could run:
gdalinfo image.tif  |grep ^Size | sed 's/Size is//g;s/ //g'.

- To read the GeoTIFF coordinates into a list or something without having to
> open each single file.
> I know that gdal_translate.exe -srcwin can read the dimensions but I need
> them all to be listed somewhere to insert them to the commands. Windows
> Explorer should be able to show the dimensions in a list, but crashes at
> GeoTiffs of that size...
>

In bash (under cygwin on windows perhaps) you could set this to a shell
variable:
XY=$(gdalinfo image.tif  |grep "^Size" | sed 's/Size is//g;s/ //g')
# Then parse out the X and Y extents individually.
x=$(echo $XY | cut -d"," -f1)
y=$(echo $XY | cut =d"," -f2)

gdalinfo can give you a bunch of other info too, try just:
gdalinfo image.tif
to see all of gdalinfo's output.

Jonah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090302/d73fc669/attachment.html


More information about the gdal-dev mailing list