Opened 8 years ago

Closed 8 years ago

Last modified 8 years 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 8 years ago.
modified contour.cpp
contour.cpp.patch (4.7 KB ) - added by dsogari 8 years ago.
patch file for contour.cpp
map.tiff (17.9 KB ) - added by dsogari 8 years ago.
sample raster
map_nan.tiff (17.9 KB ) - added by dsogari 8 years ago.
sample raster with NaN

Download all attachments as: .zip

Change History (7)

by dsogari, 8 years ago

Attachment: contour_modif.cpp added

modified contour.cpp

by dsogari, 8 years ago

Attachment: contour.cpp.patch added

patch file for contour.cpp

by dsogari, 8 years ago

Attachment: map.tiff added

sample raster

by dsogari, 8 years ago

Attachment: map_nan.tiff added

sample raster with NaN

comment:1 by Even Rouault, 8 years ago

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 by Even Rouault, 8 years ago

In 34256:

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

comment:3 by Even Rouault, 8 years ago

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