How to generate topographic contours using FOS tools?

For the creation of the OPM Mars Basemap, we have used pre-generated MOLA-based contours lines by @thare using the commercial Global Mapper software (v18), which has smoothing and removing of small features built-in. These contours were generated using:

  • Intervals: 200m and 1km
  • Smoothing 7x7 box over DEM
  • Smooth lines but with a simplify of 0.1
  • Any feature less than 2km in length were removed

As we are creating basemaps for other bodies (eg. Moon, Mercury), we would like to be able to produce similar quality (or better) contours lines from any scale DTM data products (local or regional), using free and open source (FOS) software.

We propose to experiment with gdal_contour and other tools people might know.

Resources:

1 Like

What’s the problem with gdal_contour?

We’ll figure it out! :wink:

Perhaps GRASS can help to smooth? https://grasswiki.osgeo.org/wiki/V.generalize_tutorial
Mapserver (but is that only on-the-fly?): https://mapserver.org/development/rfc/ms-rfc-94.html

for pre-processing (smoothing) a DEM there is:
ISIS3: https://isis.astrogeology.usgs.gov/Application/#Filters
GMT: https://gmt.soest.hawaii.edu/doc/5.4.4/grdfilter.html
GRASS again: https://grass.osgeo.org/grass76/manuals/r.resamp.filter.html
filtering in a GDAL VRT (kernels or using Python): https://gdal.org/drivers/raster/vrt.html
GDAL and numpy, scipy: https://gis.stackexchange.com/questions/9431/what-raster-smoothing-generalization-tools-are-available/10467#10467
OrfeoToolbox: https://www.orfeo-toolbox.org/start/
GIS Jake: https://gisjake.blogspot.com/2018/10/rasterchunkprocessingpy-installation.html?m=1

large winding discussion on filtering: http://osgeo-org.1560.x6.nabble.com/gdal-dev-downsampling-geotiff-with-a-low-pass-filter-td5385890.html

1 Like

for smoothing what I diid is to subsample MLA, then this https://gist.github.com/esisa/5849392

the result (1km and 2km contours) is on https://anrossi.carto.com/builder/892ba76d-3da2-4d0e-9445-25b10890c7fa/embed

For smoothing after creating vector lines, you can also use PostGIS. It has a great simplify function implemented: https://postgis.net/docs/ST_Simplify.html

The algorithm seems to be available in Pyhton as well: https://pypi.org/project/rdp/

1 Like