Opened 14 years ago

Last modified 9 years ago

#3778 closed enhancement

gdal_contour dtm input signed / unsigned flag — at Version 2

Reported by: moellney Owned by: warmerdam
Priority: normal Milestone:
Component: Utilities Version: svn-trunk
Severity: normal Keywords: gdal_contour signed unsigned
Cc:

Description (last modified by moellney)

Sometimes we have files that produce negative dtm values at sea-level but put unsigned integer data in png / tiff file format.

When e.g. producing a contour at 100m we get a log of small circle at the sea, because gdal_contour has no chance to see, that the extremle high numbers are negative values in effect (due to the coding of negative values in binary notation).

So how to about a flag that tells gdal_contour to reinterpret the binary data singed instead of unsigned?

Change History (3)

by moellney, 14 years ago

Attachment: Hongkong_test1.tif added

DTM Data received from SRTM NASA WMS server saved as tiff.

comment:1 by Even Rouault, 14 years ago

Resolution: invalid
Status: newclosed

The TIFF file isn't valid if it is meant at having signed values. Namely the value of the SAMPLEFORMAT tag is 1 (SAMPLEFORMAT_UINT) in your example, whereas it should be 2 (SAMPLEFORMAT_INT).

This can be corrected by example with the tiffset utility of libtiff

tiffset -s 339 1 2 Hongkong_test1.tif

in reply to:  1 comment:2 by moellney, 14 years ago

Description: modified (diff)
Resolution: invalid
Status: closedreopened

Replying to rouault:

The TIFF file isn't valid if it is meant at having signed values. Namely the value of the SAMPLEFORMAT tag is 1 (SAMPLEFORMAT_UINT) in your example, whereas it should be 2 (SAMPLEFORMAT_INT).

This can be corrected by example with the tiffset utility of libtiff

tiffset -s 339 1 2 Hongkong_test1.tif

Thanks for the hint. In tiff is seems to be possible to signal signed or unsigned. Your example works and gives nice results with gdal_contour.

But do you know if png supports signed integer?

Let me cite from the capabilities file of the nasa wms:

<Layer queryable="0">
      <Name>worldwind_dem</Name>
      <Title>SRTM derived global elevation, 3 arc-second</Title>
      <Abstract>
	A global elevation model, prepared from the 3 arc-second SRTM dataset by filling some
        of the problem areas. Prepared by the NASA Learning Technologies.
	The default style is scaled to 8 bit, non-linear.
	It is possible to request the elevation data in meters by the short_int tyle and
        requesting PNG format. The resulting PNG file will be a unsigned 16 bit per pixel
        image. The values are then the elevation in meters.
	Values are signed 16 bit integers, but PNG will present them as unsigned, leading to a 
        few areas with very large values (65000+)
	For elevation values in feet, request PNG format with the style feet_short_int.
      </Abstract>
Note: See TracTickets for help on using tickets.