<div dir="ltr"><div>Hi,</div><div><br></div><div>I am using gdal_contour to generate iso-polygons from a hillshade raster created via the gdal_dem tool. In certain situations, I am seeing a lot of tiny/narrow polygons and large polygons with long, skinny <i>whiskers</i> protruding out (and sometimes in) . In these cases, the vertices in the <i>skinny</i> areas are less than 1e-07 away from their nearest edge/vertex.</div><div><br></div><div>Here is an example of how the tool is being called (GDAL version 3.4.1):</div><div><span style="font-family:monospace">> gdal_contour -p -f GPKG -amin level -nln hillshade -fl 231 295-hillshade-polygon.tif ./295-hillshade-polygons.gpkg</span></div><div><br></div><div><span style="font-family:monospace"><font face="arial,sans-serif">For 
reference, the hillshade raster has EPSG:4326 defined as its CRS with a 
geo-pixel size of (0.044031311154586,-0.044031311154586).</font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif"><br></font></span></div><div>The diagram below depicts a simple example when working through the marching-squares algorithm by hand with a single threshold level of 231 (prior to the interpolation step):<br></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">      229               229              229<br>          x----------------x----------------x<br>          |                |                |<br>          |                |                |<br>          |     case 2     *      case 1    |<br>          |               /|\               |<br>          |              / | \              | <br>          |             /  |  \             |<br>      230 x------------*---o---*------------x 230<br>          |            |  231  |            |<br>          |            |   |   |            |<br>          |            |   |   |            |<br>          |     case 6 |   |   |  case 9    |<br>          |            |   |   |            |<br>          |            |  231  |            |<br>      230 x------------*---o---*------------x 230<br>          |             \  |  /             |<br>          |              \ | /              |<br>          |               \|/               |<br>          |    case 4      *     case 8     |<br>          |                |                |<br>          |                |                |<br>          x----------------x----------------x <br>         229              227              226</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">I would expect the vertices surrounding each of the 231 intensity values to be coincident, but the final result has the vertices in each set ~8e-08 apart</font>.<font face="arial,sans-serif">This leads me to believe there might be some precision issue in gdal_contour during bipolar edge interpolation? <br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif"><br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">I ran this same configuration through another isoline generator for comparison (see <a href="https://github.com/rveciana/raster-marching-squares">https://github.com/rveciana/raster-marching-squares</a>) and got what I would expect: a degenerate line with two sets of coincident vertices around each 231 intensity pixel location.<br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif"><br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">If necessary, I can provide a complete example with the hillshade raster and the generated polygons.<br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif"><br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">Thanks!<br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif"><br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif"><br></font></span></div></div>