[gdal-dev] gdalwarp fills nulls?

Even Rouault even.rouault at mines-paris.org
Thu Sep 10 18:56:08 EDT 2009


Selon William Kyngesburye <woklist at kyngchaos.com>:

I don't manage to reproduce your issue neither with trunk nor with 1.6.2 with a
indem.tif generated by the following python script :

import gdal
import osr

ds = gdal.GetDriverByName('GTiff').Create('indem.tif', 500, 500, 1,
gdal.GDT_Int16)
ds.SetGeoTransform([500000, 10, 0, 45000000, 0, -10])
sr = osr.SpatialReference()
sr.ImportFromEPSG(32631)
ds.SetProjection(sr.ExportToWkt())
ds.GetRasterBand(1).Fill(-32768)
ds.GetRasterBand(1).SetNoDataValue(-32768)
ones = ''
for i in range(50*50):
    ones = ones + '\001\000'
ds.GetRasterBand(1).WriteRaster(225,225,50,50, ones, 25, 25)
ds = None


and

gdalwarp -tr 100 100 -ot Int16 -r lanczos -dstnodata -32768 indem.tif outdem.tif

You need to specify -dstnodata -32768. The result I get is as expected a square
of ones at the middle of nodata values at -32768 (except that due to a strange
behaviour of lanczos you get some artifacts at the edge of the square).



> Maybe I'm missing something?  I'm trying to resample a DEM, with null/
> nodata values in oceans, using gdalwarp.  No matter what options I've
> used so far, all the resampled nodata areas get filled with 0.
>
> GDAL 1.6.2
>
> So far I've tried (src res 10, nodata -32768 defined in src):
>
> gdalwarp -tr 100 100 -ot Int16 -r lanczos indem.tif outdem.tif
> gdalwarp -tr 100 100 -ot Int16 -r lanczos -dstnodata -32768 indem.tif
> outdem.tif
> gdalwarp -tr 100 100 -ot Int16 -r lanczos -dstalpha indem.tif outdem.tif
>
> The last time I used gdalwarp, with nulls, was back at 1.5.x, and it
> worked then, though I was projecting data (-t_srs), instead of only
> resampling.  (I'd have to dig up an old 1.5 to see if it still works)
>
> -----
> William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
> http://www.kyngchaos.com/
>
> "I ache, therefore I am.  Or in my case - I am, therefore I ache."
>
> - Marvin
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>




More information about the gdal-dev mailing list