[gdal-dev] Countour polygons instead of lines

Hans Gregers Hedegaard Petersen gregers at septima.dk
Thu Oct 19 05:23:06 PDT 2017


Hi Vincent,

> I know this is old stuff (references below), but making polygons instead
> of lines would be a great option for gdal_contour IMO.
>
> It could be also another program included in gdal/app (if it is already,
> I can't find it).
>
> What do you think, shall I add that ? If yes, first or second option ?

I had a similar problem years ago, and after making consistent
orientation [1] it is simply a matter of running through the lines and
matching starting points with endpoints in the linestrings.  This is a
rather fast operation on a spatially indexed dataset.

You cannot always make polygons with them unless you are on a perfect
island - for instance I processed Denmark in tiles (over 43000 tiles
of 1x1km) and then "glued" the linestrings together afterwards. Speed
was essential, so I first glued all linestrings in a tile (which would
make a large number of closed linestrings), then between tiles (but
only for those that were not yet closed).


Cheers,

Gregers


[1]: https://trac.osgeo.org/gdal/ticket/3129


More information about the gdal-dev mailing list