Countour polygons instead of lines

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Countour polygons instead of lines

Ari Jolma
Did you ever want gdal_contour to produce polygons instead of lines?

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?

Cheers,

Ari


_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Countour polygons instead of lines

Matthew Perry-2
On Tue, Sep 2, 2008 at 2:26 PM, Ari Jolma <[hidden email]> wrote:
> Did you ever want gdal_contour to produce polygons instead of lines?
...
> I wonder what's the current situation. Does GRASS do this?
>

Indirectly, yes. You can use r.reclass to create areas of similar
elevation from the raster DEM and r.to.vect to covert to polygons.

--
Matthew T. Perry
http://www.perrygeo.net
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Countour polygons instead of lines

Ari Jolma
Matthew Perry kirjoitti:

> On Tue, Sep 2, 2008 at 2:26 PM, Ari Jolma <[hidden email]> wrote:
>  
>> Did you ever want gdal_contour to produce polygons instead of lines?
>>    
> ...
>  
>> I wonder what's the current situation. Does GRASS do this?
>>
>>    
>
> Indirectly, yes. You can use r.reclass to create areas of similar
> elevation from the raster DEM and r.to.vect to covert to polygons.
>  

Thanks for the comment,

Yes, I can do that too: http://map.hut.fi/files/misc/reclassed.png but
it's uglier than that from the contour, and at least in my
implementation there's the problem of overlapping polygons not ordered
correctly (can be seen in that example). That is because of the way the
vectorization is done. Does GRASS create polygons with holes?

For comparison: http://map.hut.fi/files/misc/from_contours.png which
shows that there are still bugs in my program :(

I use GEOS methods in the program and it turns out that the contour
lines gdal_contour creates are not always well-behaving enough.
Sometimes those lines that start from the image boundary have an extra
vertice either in the beginning of the line or at the end.

Ari

--
Prof. Ari Jolma
Environmental Management Information Technology
Teknillinen korkeakoulu / Helsinki University of Technology
tel: +358 9 451 3812 address: POBox 5300, 02015 TKK, Finland
Email: ari.jolma at tkk.fi
http://geoinformatics.tkk.fi/twiki/bin/view/Main/AriJolmaHomePage


_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Countour polygons instead of lines

Nikos Alexandris
On Wed, 2008-09-03 at 10:40 +0300, Ari Jolma wrote:
> > Indirectly, yes. You can use r.reclass to create areas of similar
> > elevation from the raster DEM and r.to.vect to covert to polygons.

Also, use the "-s" switch (in r.to.vect) to get smoothed and not edgy
polygons :-)

_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Countour polygons instead of lines

Timmie
In reply to this post by Ari Jolma
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

_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Countour polygons instead of lines

Ari Jolma
Tim,

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
results.

Ari

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


_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev