Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#2626 closed defect (wontfix)

gdal_translate fails to update nodata tag on convert 32bit to 16bit

Reported by: maphew Owned by: warmerdam
Priority: normal Milestone:
Component: Utilities Version: unspecified
Severity: normal Keywords: nodata gdal_translate
Cc:

Description

When converting an image from 32bit float to 16bit signed integer the nodata tag from the source image is retained. The nodata values within the raster are converted from -3.40282346638529e+38 to -32768. but not in the header. Example:

gdal_translate -ot int16 my32bit.tif my16bit.tif

gdalinfo -mm my16bit.tif
...snip...
Band 1 Block=1800x2 Type=Int16, ColorInterp=Gray
    Computed Min/Max=-32768.000,5973.000
  NoData Value=-3.40282346638529e+38

Attachments (1)

gdal-32to16-nodata-bug.zip (3.7 KB ) - added by maphew 16 years ago.
source and output images

Download all attachments as: .zip

Change History (6)

by maphew, 16 years ago

Attachment: gdal-32to16-nodata-bug.zip added

source and output images

comment:1 by maphew, 16 years ago

Component: defaultUtilities

This is using GDAL 1.4.4.0, released 2007/11/23, on ubuntu 8.04

comment:2 by maphew, 16 years ago

Version: unspecified1.4.4

comment:3 by Even Rouault, 16 years ago

As a workaround, you can add "-a_nodata -32768" to your gdal_translate command line

comment:4 by warmerdam, 16 years ago

Keywords: nodata gdal_translate added
Resolution: wontfix
Status: newclosed

Matthew,

This is the intended behavior. I agree it can be surprising and confusing but the automatic alternatives get very complicated and I'm not prepared to pursue them at this time. Possibly someone else might feel differently.

comment:5 by maphew, 15 years ago

Version: 1.4.4unspecified

I appreciate an automatic approach can quickly get too complicated for an issue relatively minor compared to the rest of gdal development. Perhaps a warning could be issued?

Personally, now that I've tripped over it and know it's there I'll know to step around in future. A warning might save someone else the trouble of trying to figure out what happened.

Note: See TracTickets for help on using tickets.