[Gdal-dev] Mosaicing with gdalwarp

Stephen Woodbridge woodbri at swoodbridge.com
Wed Mar 21 21:26:46 EDT 2007


Frank Warmerdam wrote:
> Stephen Woodbridge wrote:
>> Quick question. I have been generating tiles with a fixed global 
>> gridding from CCM files. Obviously along the seams between two 
>> adjacent CCM files I will generate tiles that have the same spatial 
>> extents and projection.
>>
>> What is the best way to mosaic these tiles?
>>
>> gdalwarp --config GDAL_ONE_BIG_READ on infile.tif outfile.tif
>>
>> I know that infile.tif and outfile.tif have the same coverage based on 
>> the file names. All I want to do is mosaic the infile.tif onto 
>> outfile.tif which exists. Both of these files will have no-data areas 
>> and data areas.
> 
> Steve,
> 
> This should work for what you want.  You may need to use -srcnodata and/or
> -dstnodata if these values aren't set properly in the file metadata.
> 
> Best regards,

OK, seems the nothing is as simple as it should be. I grabbed two tiles 
to give it a try.

1) I does not look like the nodata value is set in the metadata
2) these files should be the same spatial extents, but aren't *mutter* 
*mutter*

I'm not sure what the nodata value is and these were tiled out of CCM 
mrsid files. I seem to remember that there is some option like nearblack 
that can be used to set the nodata values. Is there a gdal tool that 
will help me with this?

[swoodbridge at booboo test]$ gdalinfo a.tif
Driver: GTiff/GeoTIFF
Size is 6235, 6235
Coordinate System is:
GEOGCS["WGS 84",
     DATUM["WGS_1984",
         SPHEROID["WGS 84",6378137,298.2572235629972,
             AUTHORITY["EPSG","7030"]],
         AUTHORITY["EPSG","6326"]],
     PRIMEM["Greenwich",0],
     UNIT["degree",0.0174532925199433],
     AUTHORITY["EPSG","4326"]]
Origin = (-117.750000000000000,34.000000000000000)
Pixel Size = (0.000010024716912,-0.000010024716912)
Metadata:
   AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  (-117.7500000,  34.0000000) (117d45'0.00"W, 34d 0'0.00"N)
Lower Left  (-117.7500000,  33.9374959) (117d45'0.00"W, 33d56'14.99"N)
Upper Right (-117.6874959,  34.0000000) (117d41'14.99"W, 34d 0'0.00"N)
Lower Right (-117.6874959,  33.9374959) (117d41'14.99"W, 33d56'14.99"N)
Center      (-117.7187479,  33.9687479) (117d43'7.49"W, 33d58'7.49"N)
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue

[swoodbridge at booboo test]$ gdalinfo b.tif
Driver: GTiff/GeoTIFF
Size is 2925, 2925
Coordinate System is:
GEOGCS["WGS 84",
     DATUM["WGS_1984",
         SPHEROID["WGS 84",6378137,298.2572235629972,
             AUTHORITY["EPSG","7030"]],
         AUTHORITY["EPSG","6326"]],
     PRIMEM["Greenwich",0],
     UNIT["degree",0.0174532925199433],
     AUTHORITY["EPSG","4326"]]
Origin = (-117.750000000000000,34.000000000000000)
Pixel Size = (0.000021365901645,-0.000021365901645)
Metadata:
   AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  (-117.7500000,  34.0000000) (117d45'0.00"W, 34d 0'0.00"N)
Lower Left  (-117.7500000,  33.9375047) (117d45'0.00"W, 33d56'15.02"N)
Upper Right (-117.6875047,  34.0000000) (117d41'15.02"W, 34d 0'0.00"N)
Lower Right (-117.6875047,  33.9375047) (117d41'15.02"W, 33d56'15.02"N)
Center      (-117.7187524,  33.9687524) (117d43'7.51"W, 33d58'7.51"N)
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue

[swoodbridge at booboo test]$ gdalinfo c.tif
Driver: GTiff/GeoTIFF
Size is 2925, 2925
Coordinate System is:
GEOGCS["WGS 84",
     DATUM["WGS_1984",
         SPHEROID["WGS 84",6378137,298.2572235629972,
             AUTHORITY["EPSG","7030"]],
         AUTHORITY["EPSG","6326"]],
     PRIMEM["Greenwich",0],
     UNIT["degree",0.0174532925199433],
     AUTHORITY["EPSG","4326"]]
Origin = (-117.750000000000000,34.000000000000000)
Pixel Size = (0.000021365901645,-0.000021365901645)
Metadata:
   AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  (-117.7500000,  34.0000000) (117d45'0.00"W, 34d 0'0.00"N)
Lower Left  (-117.7500000,  33.9375047) (117d45'0.00"W, 33d56'15.02"N)
Upper Right (-117.6875047,  34.0000000) (117d41'15.02"W, 34d 0'0.00"N)
Lower Right (-117.6875047,  33.9375047) (117d41'15.02"W, 33d56'15.02"N)
Center      (-117.7187524,  33.9687524) (117d43'7.51"W, 33d58'7.51"N)
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue

cp b.tif c.tif
gdalwarp --config GDAL_ONE_BIG_READ ON a.tif c.tif

[swoodbridge at booboo test]$ ls -l
total 175596
-rw-r--r--  1 swoodbridge users 122910508 Mar 22 00:50 a.tif
-rw-r--r--  1 swoodbridge users  28318972 Mar 22 00:50 b.tif
-rw-r--r--  1 swoodbridge users  28384508 Mar 22 00:54 c.tif




More information about the Gdal-dev mailing list