[gdal-dev] Contour Line Thinning

Stephen Woodbridge stephenwoodbridge37 at gmail.com
Fri Jan 1 19:09:47 PST 2021


On 1/1/2021 9:47 PM, Richard Greenwood wrote:
> On Fri, Jan 1, 2021 at 2:36 PM Stephen Woodbridge 
> <stephenwoodbridge37 at gmail.com <mailto:stephenwoodbridge37 at gmail.com>> 
> wrote:
>
>     Hi all,
>
>     I'm contouring bathemetry data using gdal_contour and it works really
>     great. The problem I have is that when depth falls off rapidly
>     like at
>     the continental shelf or into a canyon, I get too many contour lines
>     that all bunch up. If I change the contour step size to fix this,
>     then
>     the flatter areas don't get enough lines.
>
>     I wonder if anyone has any ideas on someway to thin these lines or
>     some
>     way to do adaptive contouring based on maybe something like
>     scanning the
>     image first to build a masks that represent these rapid changes in
>     depth
>     and then change the contour levels in these masked areas.
>
>     I currently contour into a postgis database, the render them using
>     mapserver into a tile cache since they are static once they are
>     computed.
>
>     I would be interested in any ideas you might have on how to tackle
>     this
>     problem.
>
>     -Steve W
>
>
> Hey Steve,
>
> Interesting problem and this isn't an answer, just my opinion. I live 
> and play in a mountainous area and frequently use USGS topo maps with 
> contour intervals of 20, 40 and 80 feet. Each map's contour interval 
> was chosen with criteria like yours - flatter land needs smaller 
> contour intervals, but steeper land can become too cluttered with a 
> small contour interval. But as a map user it drives me crazy when I 
> stitch together adjoining maps with different intervals and try to get 
> a sense of the landscape. Like this for example 
> <https://greenwoodmap.com/tetonwy/mapserver/map#zcr=7.279815109511815/2448564.5062904786/1516712.6778719614/0&lyrs=DRG,Roads,ownership> 
> where 20 foot contours adjoin 80 foot. The western half of the map is 
> much steeper than the eastern, but that's not obvious from a quick 
> look. I'd just let the bunched up contours tell the reader that hey, 
> it's really steep here!
>
> Best regards,
> Rich
>
> -- 
> Richard W. Greenwood, PLS
> www.greenwoodmap.com <http://www.greenwoodmap.com>

Hi Rich,

Yeah, I get your point. And the engineer in me agrees but users of the 
map have complained so I have to at least look into the issue.

One thought I had that might work because I'm dealing with ocean bottom 
contours is to do something like:

a) take all contours above X
b) take all contours below Y
c) take every Nth contour between X and Y

This would probably work OK for the drop off on the continental shelf at 
least for the East coast, I'd have to look at other areas since this is 
a global map, but 98% of the users are on the East coast currently but 
that is expanding.

Anyway, it is an interesting problem, I'd like to find a simple solution 
that I can build into the postGIS database where I have all the contour 
lines stored. Or find a solution that handles the generation of the 
contour lines with some kind of adaptive thinning. My guess is that it 
will not be easy to do it at the generation level, so I'll probably only 
be able to do the thinning during the rendering of the tiles.

Thank you for your thoughts on this,
-Steve


More information about the gdal-dev mailing list