You should use gdalwarp only, no ned for gdal_merge.py. The order of input datasets is important, so in your case you should use gdalwarp south.tif north.tif merge.tif
Plus you don't need a mask, the last input file will override the first one. Etienne On Fri, Apr 13, 2012 at 4:09 PM, Gregory, Matthew <[email protected]> wrote: > Hi all, > > I don't think I'm understanding correctly how to use masking bands. My goal > is to create a mosaic between two adjacent rasters using mask bands on each > raster to define the valid data. As a test, I have two single band GeoTiffs > (north.tif and south.tif) that overlap by about 400 rows. I use the > following Python script to create a small mask at the top center of the south > image which creates the desired .msk file: > > from osgeo import gdal, gdalconst > ds = gdal.Open('south.tif', gdalconst.GA_ReadOnly) > ds.CreateMaskBand(2) > rb = ds.GetRasterBand(1) > mask = rb.GetMaskBand() > data = mask.ReadAsArray() > data[:] = 255 > data[0:500,2500:3000] = 0 > mask.WriteArray(data) > ds = None > > Then I try to merge the two images together: > > gdal_merge.py -o merge.tif -of GTiff -createonly north.tif south.tif > gdalwarp north.tif south.tif merge.tif > > I was expecting that the masked pixels from south.tif would be considered > NODATA allowing the north.tif pixels to 'shine through' in that location. > Instead the original pixel values from south.tif also show up in the mosaic. > > thanks, matt > _______________________________________________ > gdal-dev mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/gdal-dev _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
