[gdal-dev] How Can I gdalwarp From One Image to a Larger Spatial Area While Leaving Missing Data Blank in the Destination?

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Wed Feb 5 05:02:56 PST 2014


Peter Willis <pwillis <at> aslenv.com> writes:

> 
> Hello,
> 
> Sorry about the title but it's a bit of a bear finding answers if the
> headers don't show the actual topic.
> But I digress.
> 
> My Issue:
> I have an input image that covers coordinates 0,0 to 450,350 UTM zone 13
> North and the pixel size is 1 meter.
> 
> I want to mosaic pixels 0,0 to 25,25 into a coverage of UTM coordinates
> -25,-25 : 25, 25 at the output in 1 meter pixels.
> This should show a 25x25 square portion of the image in one corner of the
> 50x50 output image.
> 
> 'gdal_translate' will not do this because  -25,-25  are outside the bounds
> of the original image.
> 
> I have tried the following with gdalwarp:
> 
> gdalwarp -overwrite -te -25 -25 25 25 -tr 1 1  ./input.tif ./output.tif
> 
> This does not work. I get the following error:
> 
> ERROR 1: Unable to compute a transformation between pixel/line
> and georeferenced coordinates for ./input.tif.
> There is no affine transformation and no GCPs.
> 
> There is geography applied to the input file.
> 
> What am I doing wrong ?

Hi,

This is funny. GDAL seems not to believe in images with origo at 0,0.
I tested with some dummy png file
gdal_translate -of gtiff -co tfw=yes -co profile=baseline test.png test.png
test.tif
Input file size is 588, 321
0...10...20...30...40...50...60...70...80...90...100 - done.

It does not create a tfw file. Now this fails
gdalwarp test.tif test2.tif
ERROR 1: Unable to compute a transformation between pixel/line
and georeferenced coordinates for test.tif.
There is no affine transformation and no GCPs.

I made tfw file test.tfw by hand as
1
0
0
-1
0
0

and then this is successful
gdalwarp test.tif test2.tif
Creating output file that is 588P x 321L.
Processing input file test.tif.
0...10...20...30...40...50...60...70...80...90...100 - done.

and also what you want to do
gdalwarp -te -1000 -1000 1000 1000  test.tif testi3.tif
Creating output file that is 2000P x 2000L.
Processing input file test.tif.
0...10...20...30...40...50...60...70...80...90...100 - done.

So I feel there is a bug if corner coordinates are 0,0. Please verify with a
handwritten tfw file and images with origo at, let's say, 1,1.

-Jukka Rahkonen-



> Thanks for any help.
> 
> Peter
> 






More information about the gdal-dev mailing list