Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#6519 closed defect (fixed)

contour generation does not handle NaN as nodata correctly

Reported by: dsogari Owned by: warmerdam
Priority: normal Milestone: 2.1.1
Component: Algorithms Version: 2.1.0
Severity: normal Keywords: contour nodata nan
Cc:

Description

The code of GDALContourGenerate in alg/contour.cpp does not take care of NaN as the nodata value. If the gdal_contour utility is applied to two equivalent datasets, but one using normal number as nodata and the other using NaN, then the resulting contours are different.

The difference appears in the transition from valid pixels to nodata pixels, where, in the NaN version, the contour lines are cut short (they do not touch the valid pixel boundary).

I tried modifying the code to handle the case for NaNs? and it gave the expected result, so I'm sharing it with you. I'm not shure whether the fixes are 100% ok, though.

The modified contour.cpp is attached, as well as a patch file and two sample rasters for testing. I appreciate any feedback. Thanks

Attachments (4)

contour_modif.cpp (56.4 KB) - added by dsogari 18 months ago.
modified contour.cpp
contour.cpp.patch (4.7 KB) - added by dsogari 18 months ago.
patch file for contour.cpp
map.tiff (17.9 KB) - added by dsogari 18 months ago.
sample raster
map_nan.tiff (17.9 KB) - added by dsogari 18 months ago.
sample raster with NaN

Download all attachments as: .zip

Change History (7)

Changed 18 months ago by dsogari

Attachment: contour_modif.cpp added

modified contour.cpp

Changed 18 months ago by dsogari

Attachment: contour.cpp.patch added

patch file for contour.cpp

Changed 18 months ago by dsogari

Attachment: map.tiff added

sample raster

Changed 18 months ago by dsogari

Attachment: map_nan.tiff added

sample raster with NaN

comment:1 Changed 18 months ago by Even Rouault

Resolution: fixed
Status: newclosed

In 34255:

GDALContourGenerate(): handle the case where the nodata value is NaN (derived from patch by dosgari, closes #6519)

comment:2 Changed 18 months ago by Even Rouault

In 34256:

GDALContourGenerate(): handle the case where the nodata value is NaN (derived from patch by dosgari, closes #6519)

comment:3 Changed 18 months ago by Even Rouault

Component: defaultAlgorithms
Milestone: 2.1.1
Note: See TracTickets for help on using tickets.