[gdal-dev] Re: Countour polygons instead of lines

Ari Jolma ari.jolma at tkk.fi
Wed Sep 10 01:54:39 EDT 2008


I got a bit swamped into the polygonize thing, which is at the heart of 
what the GRASS people suggested to me. There's now a polygonize method 
in GDAL too (thanks to Frank), with which one can create those 
pixel-edged polygons of reclassed rasters. I haven't yet looked into the 
smoothing much yet but GRASS seems to have some kind of simple smoothing 
built-in into its polygonize method. GEOS has smoothing and simplifying 
methods, even such that keep topology correct, but I don't believe they 
would be easy to use for the complex polygons one gets from the polygonize.

There are some bugs in my contour -> polygon Perl code and it produces 
overlapping polygons so it's far from perfect, but may produce nicer 


Tim Michelsen kirjoitti:
> Hello!
> Although your message is already some days old I wanna respond.
>> Did you ever want gdal_contour to produce polygons instead of lines?
> Yes!
>> I made a small Perl program that uses the Perl bindings to GDAL and 
>> which converts the lines into polygons. The polygons represent 
>> "plates" of equal elevation and thus overlap. The polygons are stored 
>> into a new layer in such an order that ordered rendering of them 
>> produces a nice visualization. Visualization is my main goal here - I 
>> want to get a similar effect as in some weather forecasts. However, 
>> transparency does not work as expected in standard viewers because of 
>> overlapping polygons. Here's an example created from DEM: 
>> http://map.hut.fi/files/misc/contour_polygons.png
>> The code is also at http://map.hut.fi/files/misc/
>> I found this by googling: 
>> http://lists.maptools.org/pipermail/fwtools/2005-November/000199.html
>> I wonder what's the current situation. Does GRASS do this?
> It seems that GRASS cannot do this in a satisfying way. Or at least it 
> appears to be (don't wanna offend any GRASS dev/user).
> Here I asked fro something similar:
> http://thread.gmane.org/gmane.comp.gis.grass.user/24889
> The maps I created with the suggested approach looked exactly as your 
> screenshots. The converted vectors didn't follow the countourlines 
> smouthly. Instead, the borders retraind the pixel-like raster outline.
> Matplotlib and other plotting programs (matlab, IDL) can do this (see 
> the examples here: ).
> So either
> * plotting programs do an inaccurate interpolation
> or
> * the GRASS approach is too complicated that even experience users 
> don't find it.
> Kind regards,
> Timmie

Prof. Ari Jolma
Environmental Management Information Technology
Teknillinen Korkeakoulu / Helsinki University of Technology
tel: +358 9 4511 address: POBox 5300, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://geoinformatics.tkk.fi

More information about the gdal-dev mailing list