[Gdal-dev] Gdalwarp resolution

Sampson, David dsampson at NRCan.gc.ca
Fri Nov 24 13:22:37 EST 2006

Hey list,

Just trying to tighten up my GDAL command line calls.

The -outsize option noted bellow changes the size and geographic
position of the image. The upper left corner locks into the right place,
but the smaller image produced by the -outsize option is then no longer
geo-refed on the other three points.

This is my solution so far.

gdal_translate -gcp 378.19 196.43 -76.777261  45.67899 -gcp 6013.13
282.36 -76.744739  45.678655 -gcp 5890.36 7565.55 -76.745361  45.649344
-gcp 290.14 7492.18 -76.777866  45.649679 -scale  -ot byte  -a_srs
epsg:4326 -mo "Area_or_Point = Area"  A38_001.tif .\work\iA38_001.tif


gdalwarp -tr 0.0000116774 -0.0000082992 -s_srs epsg:4326 -t_srs
epsg:4326 .\work\iA38_001.tif .\gdal_geo\oA38_001.tif

Has the bug with geo-referencing using GCP's been fixed that was
reported as a bug in the following message?

It would be great if the -outsize % % option worked and kept the
geograhic co-ordinates of all four corners.

Has this approach actualy worked for anyone georeferencing images using
FWTools Windows v 1.0.7 or v 1.0.9?  It uses gdal 1.3.2 I believe, which
is connected to the bug report listed bellow.

[Gdal-dev] gdal does not write gcp projection
Vincent Schut schut at sarvision.nl
Tue Nov 14 04:36:43 EST 2006

    * Previous message: [Gdal-dev] swig/python/setup.py
    * Next message: [Gdal-dev] GeoQuadTree - an open format for storing
georeferenced images
    * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Hi Frank, list,

I just filed a bug report 
(http://bugzilla.remotesensing.org/show_bug.cgi?id=1354) on an issue 
we're running into since gdal 1.3.2: when creating a geotiff file with 
gcp's, the gcp projection is not written to the file. In 1.3.1 this was 
working correctly, but in 1.3.2 and cvs from today it is not.

See the bug report for a simple python test case.


-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com] 
Sent: November 22, 2006 10:47
To: Sampson, David
Cc: gdal-dev at lists.maptools.org
Subject: Re: [Gdal-dev] Gdalwarp resolution

Sampson, David wrote:
> Hey folks,
> I am trying to move a 800 dpi to a 300 dpi image. The src image was 
> created using gdal_translate to assign SRS, 4 GCP's and change from 
> 16bit to 8bit image. Src image has the following meta_tags
> Metadata:
>   TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
>   Area_or_Point =Area
> The command line I am using is:
> gdalwarp -tr 300 300 oA38_001.tif S_A38_001.tif
> But I get this error
> Creating output file that is 0P x 0L.
> ERROR 1: Attempt to create 0x0x1 TIFF file, but width, height and 
> bands must be positive.


The "dpi printing resolution" information kept in some TIFF files is
completely disconnected from the georeferencing model of GDAL.  So the
-tr flag to gdalwarp is about setting the resolution in the geo
coordinate system of the image, but this image likely has none.

If you just want to downsample the image, you could try:

  gdal_translate -outsize 37.5% 37.5% in.tif out.tif

If you also want to override the resolution metadata tags (possibly
necessary to make printing software print properly) try:

  gdal_translate -outsize 37.5% 37.5% \
      in.tif out.tif

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,

More information about the Gdal-dev mailing list