[gdal-dev] Gdal contour number of contour with -p

Even Rouault even.rouault at spatialys.com
Fri Sep 28 08:50:41 PDT 2018


On mercredi 26 septembre 2018 09:30:53 CEST Julien Cabieces wrote:
> Hi,
> 
> I notice that executing gdal_contour has different number of contour
> with or without -p option.
> 
> gdal_contour  -b 1 -a level -fl 1 -f GPKG NETCDF:"/tmp/myfile.nc":MYVAR
> /tmp/outfile.gpkg
> 
> This generates one contour line.
> 
> gdal_contour  -p -b 1 -a level -fl 1 -f GPKG
> NETCDF:"/tmp/myfile.nc":MYVAR /tmp/outfile.gpkg
> 
> This generates two contour polygons, one where all values are greater
> than 1 and other one where all values are lesser than 1.
> 
> I was wondering if it wouldn't be better to generate only one polygon
> contour where all values are greater than 1, in order to keep the same
> contour number with or without the option.

This is the classical problems of intervals and sticks :-)
Polygons are intervals, and lines are sticks, so I don't find it odd that you 
don't get the same number of objects. Having the union of polygons to fill the 
raster extent seems to me to be a desirable property.

Side question: I was wondering if the exterior polygon a hole at the place 
where the interior polygon is ? ie are polygons properly disjoint ?

The question is more on the semantics of the attributes created for polygons. 
For clarity, we should probably have two attributes, one with the minimum 
value and one with the maximum one. That would make sense especially when used 
the -fl options with irregular levels. So perhaps a -a_min and -a_max could be 
useful for polygons.
Or if we have a single value, we should precisely define if it is the minimum 
or the maximum value.

Even


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list