[gdal-dev] Gdal_Translate Geotransform error

Frank Warmerdam warmerdam at pobox.com
Mon Dec 3 11:05:49 EST 2007


Andrew de Klerk wrote:
> I have done some searching to try solve my problem, but have been 
> unsuccessful. I am relatively new to gdal, but not new to GIS. I 
> apologise if my question's are basics..but an answer would help me 
> significantly. I am running the latest build of Gdal for windows (1.43), 
> and using the pre-compiled binaries. So here is my primary and secondary 
> question:

Andrew,

Note that the current release is 1.4.4. 1.4.3 was retracted due to
subtle ABI issues though that is quite unrelated to your problem.

> I have a tif file which i want to clip at certain coordinates, so I call 
> the following command:
> 
> "gdal_translate -projwin 16.25 -28.5 16.5 -28.75 
> H:\1_50000_April2007\2816\2816CB_2003_ED2_GEO.TIF 2816cb.tif"
> 
> On running this i get the following error:
> 
> "Input file size is 8267, 10629
> 
> The -projwin option was used, but the geotransform is
> 
> rotated.  This configuration is not supported."
> 
>  
> 
> I have checked my input images and coordinates passed through with 
> projwin, and all seem fine. Gdalinfo of the files reveals the following 
> coordinate information:
> 
> Upper Left  (  16.1928674, -28.4559735) ( 16d11'34.32"E, 28d27'21.50"S)
> 
> Lower Left  (  16.1904570, -28.8619556) ( 16d11'25.65"E, 28d51'43.04"S)
> 
> Upper Right (  16.5508568, -28.4576272) ( 16d33'3.08"E, 28d27'27.46"S)
> 
> Lower Right (  16.5484465, -28.8636093) ( 16d32'54.41"E, 28d51'48.99"S)
> 
> Center      (  16.3706569, -28.6597914) ( 16d22'14.36"E, 28d39'35.25"S)
> 
> So my question is...what do I do to correct the error. I see no related 
> messages between gdal_translate and geotransform. Do I need to do some 
> programming to solve this problem? I shouldn’t think so, as what I am 
> doing is pretty basic.

The problem is (as the error indicates) that your image is rotated or
sheared.  For example, if you look at the upper left x and lower left x
they do not match in the above report.  Since the differences are small
I'm guessing your images are only slightly rotated.

The -projwin switch just takes the indicated window and attempts
to turn it into a rectangle in pixel/line coordinates.  But a particular
georeferenced rectangular window in georef coordinates cannot be expressed
as a simple grid aligned rectangle in pixel/line coordinates on a rotated
or sheared image so it gives up.

If you want to produce "north up" result images then you want to do a
more general sort of warp, and should use gdalwarp.  If you just want to
cut grid aligned rectangles out of the source images then you will need
to specify them in pixel/line coordinates using -srcwin instead of -projwin.

> Second/third question is..if i do a straight translate to geotiff, my 
> output image is 85Mb, while my input is only 6Mb (also tif, but with LZW 
> compression) - how do I force LZW or export a file of the same size, or 
> smaller, as the original?.

You can specify compression using the COMPRESS creation option.

eg.

  gdal_translate in.tif out.tif -co COMPRESS=LZW

 >  I tried ECW but i received a "no support"
> message. Is ECW supported?

There is ECW support available with GDAL but it is not built in by
default because it depends on external libraries - the ECW SDK from
ERMapper/Leica.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list