[gdal-dev] Problem with nodata values

Markus Neteler neteler at osgeo.org
Tue Aug 11 05:42:08 EDT 2009


On Wed, Jul 29, 2009 at 9:08 AM, Rainer M Krug<r.m.krug at gmail.com> wrote:
> On Fri, Jul 24, 2009 at 5:44 PM, Frank Warmerdam<warmerdam at pobox.com> wrote:
>> Rainer M Krug wrote:
>>>
>>> Hi
>>>
>>> I have a geotiff and want to use gdalwarp to warp to it into a
>>> different projection.
>>> I do the following:
>>>
>>> gdalwarp -s_srs EPSG:32734 -t_srs '+proj=longlat +ellps=WGS84
>>> +no_defs' Outeniqua.tiff Outeniqua_wgs84.tiff
>>>
>>> The problem is, that in Outeniqua_wgs84.tiff, the nodata values from
>>> Outeniqua.tiff become translated into -9999. In addition, the areas
>>> new to Outeniqua_wgs84.tiff (due to the warping) become 1.
>>>
>>> Which options do I have to use to keep the nodata values and to make
>>> the values of the "new areas" also as nodata values?
>>
>> Rainer,
>>
>> I believe you want to pass the warp option INIT_DEST=-9999 to set all pixels
>> that do not come from the source file to -9999.
>
> Thanks a lot - that solved it partly. I now have all original pixels
> unequal to NULL now warped as they should be. Only slight problemk
> now: all NULL values from the input file, are now -9999 and I would
> prefer to heve them as NULL. I managed that by using gdal_translate
> and the -a_nulldata option, but shouldn't that be possible in
> gralwarp?

I just ran into the same problem...
Having a raster map of Italy with the sea being NULL, I obtain the
gdalwarped map with the sea becoming 0.

This works:

MAP=Italy
gdalwarp -r bilinear -tr 1000 1000 \
         -srcnodata "-32768" -dstnodata "-32768" -wo "INIT_DEST=-32768" \
         -t_srs epsg:32632 ${MAP}_LL.tif ${MAP}_UTM32.tif

Suggestion: add to the manual of gdalwarp:

-dstnodata: ... See also INIT_DEST in GDALWarpOptions::papszWarpOptions docs.

Markus


More information about the gdal-dev mailing list