[gdal-dev] Setting NODATA to -nan

Homme Zwaagstra hrz at geodata.soton.ac.uk
Wed Jul 15 06:56:09 PDT 2015



On 15/07/15 14:18, Even Rouault wrote:
> On Wednesday 15 July 2015  10:21:54 Homme Zwaagstra wrote:
 >> Hello,
 >>
 >> I've got the following raster exported from GRASS using `r.out.gdal`:
 >>
 >> gdalinfo ppp-2015.tif
 >> Driver: GTiff/GeoTIFF
 >> Files: ppp-2015.tif
 >>         ppp-2015.tif.aux.xml
 >> Size is 432017, 216009
 >> Coordinate System is:
 >> GEOGCS["WGS 84",
 >>      DATUM["WGS_1984",
 >>          SPHEROID["WGS 84",6378137,298.257223563,
 >>              AUTHORITY["EPSG","7030"]],
 >>          AUTHORITY["EPSG","6326"]],
 >>      PRIMEM["Greenwich",0],
 >>      UNIT["degree",0.0174532925199433],
 >>      AUTHORITY["EPSG","4326"]]
 >> Origin = (-180.000000000000000,90.000000000000000)
 >> Pixel Size = (0.000833300541414,-0.000833298612558)
 >> Metadata:
 >>    AREA_OR_POINT=Area
 >> Image Structure Metadata:
 >>    COMPRESSION=DEFLATE
 >>    INTERLEAVE=BAND
 >> Corner Coordinates:
 >> Upper Left  (-180.0000000,  90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"N)
 >> Lower Left  (-180.0000000, -90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"S)
 >> Upper Right ( 180.0000000,  90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"N)
 >> Lower Right ( 180.0000000, -90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"S)
 >> Center      (   0.0000000,   0.0000000) (  0d 0' 0.01"E, 0d 0' 0.01"N)
 >> Band 1 Block=256x256 Type=Float32, ColorInterp=Gray
 >>    NoData Value=nan
 >>    Metadata:
 >>      COLOR_TABLE_RULES_COUNT=5
 >>      COLOR_TABLE_RULE_RGB_0=0.000000e+00 1.681282e+03 255 255 0 0 255 0
 >>      COLOR_TABLE_RULE_RGB_1=1.681282e+03 3.362563e+03 0 255 0 0 255 255
 >>      COLOR_TABLE_RULE_RGB_2=3.362563e+03 5.043845e+03 0 255 255 0 0 255
 >>      COLOR_TABLE_RULE_RGB_3=5.043845e+03 6.725127e+03 0 0 255 255 0 255
 >>      COLOR_TABLE_RULE_RGB_4=6.725127e+03 8.406408e+03 255 0 255 255 0 0
 >>      Generated_with=GRASS GIS 7.0.0
 >>
 >> As you can see the NoData is set to `nan`.  However, within the data 
it is
 >> actually `-nan`:
 >>
 >> gdallocationinfo ppp-2015.tif -wgs84 42.0776 30.9305
 >> Report:
 >>    Location: (266503P,70886L)
 >>    Band 1:
 >>      Value: -nan
 >>
 >> I have tried to force the NoData to `-nan` as follows but with no joy:
 >>
 >> gdal_translate -a_nodata '-nan' -of VRT ppp-2015.tif ppp-2015.vrt
 >>
 >> gdalinfo ppp-2015.vrt
 >> Driver: VRT/Virtual Raster
 >> Files: ppp-2015.vrt
 >>         /data/data/ppp_v2c_2015/ppp-2015.tif
 >> Size is 432017, 216009
 >> Coordinate System is:
 >> GEOGCS["WGS 84",
 >>      DATUM["WGS_1984",
 >>          SPHEROID["WGS 84",6378137,298.257223563,
 >>              AUTHORITY["EPSG","7030"]],
 >>          AUTHORITY["EPSG","6326"]],
 >>      PRIMEM["Greenwich",0],
 >>      UNIT["degree",0.0174532925199433],
 >>      AUTHORITY["EPSG","4326"]]
 >> Origin = (-180.000000000000000,90.000000000000000)
 >> Pixel Size = (0.000833300541414,-0.000833298612558)
 >> Metadata:
 >>    AREA_OR_POINT=Area
 >> Image Structure Metadata:
 >>    INTERLEAVE=BAND
 >> Corner Coordinates:
 >> Upper Left  (-180.0000000,  90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"N)
 >> Lower Left  (-180.0000000, -90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"S)
 >> Upper Right ( 180.0000000,  90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"N)
 >> Lower Right ( 180.0000000, -90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"S)
 >> Center      (   0.0000000,   0.0000000) (  0d 0' 0.01"E, 0d 0' 0.01"N)
 >> Band 1 Block=128x128 Type=Float32, ColorInterp=Gray
 >>    NoData Value=nan
 >>    Metadata:
 >>      COLOR_TABLE_RULES_COUNT=5
 >>      COLOR_TABLE_RULE_RGB_0=0.000000e+00 1.681282e+03 255 255 0 0 255 0
 >>      COLOR_TABLE_RULE_RGB_1=1.681282e+03 3.362563e+03 0 255 0 0 255 255
 >>      COLOR_TABLE_RULE_RGB_2=3.362563e+03 5.043845e+03 0 255 255 0 0 255
 >>      COLOR_TABLE_RULE_RGB_3=5.043845e+03 6.725127e+03 0 0 255 255 0 255
 >>      COLOR_TABLE_RULE_RGB_4=6.725127e+03 8.406408e+03 255 0 255 255 0 0
 >>      Generated_with=GRASS GIS 7.0.0
 >>
 >> Even editing the VRT to contain `<NoDataValue>-nan</NoDataValue>` 
yields a
 >> positive nan value in gdalinfo.
 >>
 >> This looks like it might be a GDAL bug to me?  Is there a way I can 
specify
 >> `-nan` as the NODATA value for this dataset without regenerating it
 >> (it's quite
 >> large)?
 >
 > Hi Homme,
 >
 > I wasn't aware of this negative not a number variation. Could you 
create a
 > ticket with a small extract of the dataset so as to inspect the 
hexadecimal
 > representation of this -nan value ?

Thanks Even,

I have submitted <https://trac.osgeo.org/gdal/ticket/6036> with an 
attached TIFF
infested with `-nan` values.

While researching this I cam across this question
<http://stackoverflow.com/q/3772835> which might contain some information of
interest.

Let me know if I can do anything else to help.

Best regards,

Homme

>
 >
 > Even
 >
 >
 >>
 >> Many thanks,
 >>
 >> Homme
 >>
 >> _______________________________________________
 >> gdal-dev mailing list
 >> gdal-dev at lists.osgeo.org
 >> http://lists.osgeo.org/mailman/listinfo/gdal-dev
 >


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150715/f8994c5e/attachment-0001.html>


More information about the gdal-dev mailing list