[gdal-dev] Countour polygons instead of lines

Jamie Adams jaadfoo at gmail.com
Thu Oct 19 10:57:10 PDT 2017


>From a user perspective, this can be done pretty easily using gdal_calc.py
& gdal_polygonize.py. I've used this technique in the past several times.
This doesn't help with gdal_contour of course, but is a viable way of doing
the same thing. Maybe worth considering as a new python tool.

Using a random SRTM tile in bash:

for iso in 800 1000 1200 1400 1600
do
gdal_calc.py --NoDataValue=0 -A N22E005.tif --calc="A>${iso}" --outfile
${iso}.tif
gdal_polygonize.py -f "ESRI Shapefile" ${iso}.tif ${iso}.shp
done

On Thu, Oct 19, 2017 at 5:47 AM, Vincent Mora <vincent.mora at oslandia.com>
wrote:

> Hi Gregers,
>
> Thanks for your reply.
>
> The question was not "how to" yet, but "shall I" ;o)
>
> I think I did something similar to the "ends matching" in a python
> script that creates those polygons (in a particular context that also
> requires tiling).
>
> What I'd like to know, is if there is a reason why it's not already
> available in gdal, since there is the need for that and apparently algos
> to reach the goal.
>
> > You cannot always make polygons with them unless you are on a perfect
> island
>
> I'm not sure I understand the that. The polygons I have in mind are
> polygons with holes (multipolygons for a given class actually), is it
> related to what you're saying ?
>
>
> V.
>
>
> Le 19/10/2017 à 14:23, Hans Gregers Hedegaard Petersen a écrit :
> > 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
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171019/254bf3c3/attachment.html>


More information about the gdal-dev mailing list