[gdal-dev] Contour Line Thinning

Andrew C Aitchison andrew at aitchison.me.uk
Sat Jan 2 06:17:57 PST 2021


On Fri, 1 Jan 2021, Stephen Woodbridge wrote:

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

Swisstopo appears to draw the contours until they are very close together, 
then draw *vertical* lines for the steepest sections
https://map.geo.admin.ch/?lang=en&topic=swisstopo&bgLayer=ch.swisstopo.swissimage&E=2643456.18&N=1158412.03&zoom=9&layers=ch.swisstopo.amtliches-strassenverzeichnis,KML%7C%7Chttps:%2F%2Fpublic.geo.admin.ch%2FX-zbcggpRz-GgyBn6mrj2Q,ch.bav.haltestellen-oev,ch.swisstopo.pixelkarte-farbe-pk25.noscale&layers_opacity=0.85,1,1,1&layers_visibility=false,false,true,true&catalogNodes=1396,1397
Of course these maps have the reputation for being hand drawn and the most 
beautiful available anywhere; not sure how you could do something similar
automatically.

(I was going to say that these are expensive maps, but I see that
  they will be available online free of charge from March 2021
  https://www.swisstopo.admin.ch/en/swisstopo/free-geodata.html
)

> 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
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>

-- 
Andrew C. Aitchison					Kendal, UK
 			andrew at aitchison.me.uk


More information about the gdal-dev mailing list