[gdal-dev] python gdal.gdal.ReprojectImage not masking NoData in signed byte geotifs

Colin Talbert talbertc at usgs.gov
Fri May 11 12:29:03 EDT 2012


Hello all,
    I'm running into an issue reprojecting a single band geotif in python. 

My code works fine on pixel types other than signed byte.  What I'm seeing
is that the interpolation that includes a nodata pixel uses the literal
nodata value (-128 is the nodata but I think this is being interpreted as
128).  In my example I have a grid with values between 0 and 60 and areas 
of
nodata.  Pixels bordering the nodata areas have values up to 126 in the
output.   I've also tried to recreate this process using gdalwarp and I
think I'm getting the same problem.

Thanks for any help or projections.  FYI I'm on GDAL 1.8

Attached are the small test files I'm using.  BigSage.tif is the input,
template2.tif has the projection info and extent I'm using for the output,
output.tif is what I'm getting.
http://osgeo-org.1560.n6.nabble.com/file/n4967005/BigSage.tif BigSage.tif 
http://osgeo-org.1560.n6.nabble.com/file/n4967005/template2.tif
template2.tif  
http://osgeo-org.1560.n6.nabble.com/file/n4967005/output.tif
output.tif 

Below is a striped down version of my code:
tifDriver = gdal.GetDriverByName("GTiff")
tmpOutDataset = tifDriver.Create(tmpOutput, width, height, 1, 
gdal.GDT_Byte,
["PIXELTYPE=SIGNEDBYTE"])
#omited code to set cell size, geotransform, NoData, projection
tmpOutDataset.GetRasterBand(1).PixelType = "SIGNEDBYTE"
tmpOutDataset.GetRasterBand(1).SetMetadata({'PIXELTYPE': 'SIGNEDBYTE'},
'IMAGE_STRUCTURE')

err = gdal.ReprojectImage(srcDs, tmpOutDataset, sourcesrs.ExportToWkt(), 
                                templatesrs.ExportToWkt(),
gdal.GRA_Bilinear)


--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/python-gdal-gdal-ReprojectImage-not-masking-NoData-in-signed-byte-geotifs-tp4967005.html

Sent from the GDAL - Dev mailing list archive at Nabble.com.



Colin Talbert
GIS Specialist
US Geological Survey - Fort Collins Science Center
2150 Centre Ave. Bldg. C
Fort Collins, CO 80526

(970) 226-9425
talbertc at usgs.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120511/47e8ead5/attachment.html


More information about the gdal-dev mailing list