[gdal-dev] GDAL contouring problem

Frank Warmerdam warmerdam at pobox.com
Sun Nov 28 23:24:56 EST 2010


Ole Nielsen wrote:
> I am posting this again without test files attached due the 50K size 
> limit. Anyone who wants to see them, please contact me directly.
> 
>  
> 
> --
> 
> We have observed interesting anomaly with gdal_contour when one of the 
> fixed levels is zero.
> 
> If the zero contour is expressed as 0.0 (or indeed 0.0000) gdal_contour 
> replies with the standard Usage message (see below). If the zero contour 
> is expressed as the integer 0 (or 0.00000001) it works and produces the 
> expected contours.

Ole,

The gdal_contour program has some rather hokey heuristics to try and
recognise the end of the list of contour levels.  The code looks like:

         else if( EQUAL(argv[i],"-fl") && i < argc-1 )
         {
             while( i < argc-1
                    && nFixedLevelCount
                              < (int)(sizeof(adfFixedLevels)/sizeof(double))
                    && (atof(argv[i+1]) != 0 || EQUAL(argv[i+1],"0"))
                    && !EQUAL(argv[i+1], "-3d"))
                 adfFixedLevels[nFixedLevelCount++] = atof(argv[++i]);
         }

So basically, it assumes everything is a "level" until something that
has a numeric value of 0 is encounter that isn't the specific string
"0".  So your analysis of the problem is essentially correct, but it is
more or less intentional as we try to support a list of levels with no
explicit "end of list" marker in the arguments to the command.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list