planetiler icon indicating copy to clipboard operation
planetiler copied to clipboard

[FEATURE] contour lines

Open markuman opened this issue 4 years ago • 10 comments

I'd like to add contour lines.

markuman avatar Oct 28 '21 18:10 markuman

Yes! I was thinking the same thing, as well as hillshading polygons derived from the same elevation data. Do you have any background knowledge on generating contour lines?

I did some work on graphhopper with elevation data so I know it shouldn't be too hard to access free public data from Java. I'm not too familiar with generating isolines but it looks like marching squares used by d3-contour is pretty standard?

msbarry avatar Oct 29 '21 00:10 msbarry

Do you have any background knowledge on generating contour lines?

Unfortunately not.

markuman avatar Oct 29 '21 06:10 markuman

This guide also contains some useful info: https://github.com/nst-guide/terrain#contours-1 - it looks like DEM files can be processed in isolation then the results merged, which fits in well with Flatmap's goal of saturating cpus and limiting memory and disk usage. If the result gets blocky at higher zoom levels, there's also https://docs.geotools.org/stable/javadocs/org/geotools/geometry/jts/JTS.html#smooth-org.locationtech.jts.geom.Geometry-double-

msbarry avatar Oct 29 '21 12:10 msbarry

Some interesting and possibly valuable links I collected when looking for global contour lines and hillshade from open data:

Free terrain tiles from aws:

  • https://registry.opendata.aws/terrain-tiles/
  • on demand generated hillshades from aws terrain-tiles https://terradactile.sparkgeo.com/
    • Technical background: https://sparkgeo.com/blog/terradactile-generate-cogs-from-aws-terrain-tiles/
    • Source code: https://github.com/sparkgeo/terradactile-lambda/blob/master/terradactile/terradactile/app.py
    • GDAL Docker image https://github.com/developmentseed/geolambda
  • https://www.openslopemap.org/karte/
  • Global elevation data: http://www.viewfinderpanoramas.org/Coverage%20map%20viewfinderpanoramas_org3.htm

Terrain Tiles:

  • https://bertt.wordpress.com/2022/05/24/custom-maplibre-terrain-tiles/
  • https://www.eorc.jaxa.jp/ALOS/en/dataset/aw3d30/aw3d30_e.htm
  • https://maplibre.org/news/2022-05-20-terrain3d/#10.46/47.2713/11.4/21.6/41

Generate hillshade

  • https://github.com/interline-io/planetutils#elevation_tile_download
  • https://github.com/Karry/hillshade-tile-server
  • https://github.com/clhenrick/gdal_hillshade_tutorial
  • https://www.kreidefossilien.de/en/miscellaneous/custom-hillshading-for-osmand

Generate contours

  • https://github.com/RomainQuidet/generate-osm-contours

  • https://github.com/joe-akeem/contour-tiles

  • hillshade/contours and script for France:

    • https://www.data.gouv.fr/fr/datasets/bd-alti-r-25-m-tuiles-pour-courbes-de-niveau-et-ombrage-dynamiques-1/
    • https://makina-corpus.com/sig-webmapping/optimisation-tuiles-mnt-rgb-ombrage-dynamique-mapbox-gl-maplibre-gl
    • https://makina-corpus.com/sig-webmapping/representation-des-modeles-numeriques-de-terrain-sur-le-web-ombrage-et-3d
    • https://github.com/lokkelvin2/kepler.gl-offline#hillshade-generation

pgassmann avatar Jul 27 '23 15:07 pgassmann

I just now found out about client-side generated hillshade and contour-lines with maplibre GL JS.

  • https://github.com/onthegomap/maplibre-contour
  • https://maplibre.org/maplibre-style-spec/layers/#hillshade

This works globally, based on the terrain tiles from aws. grafik https://onthegomap.github.io/maplibre-contour/#12.03/46.14026/7.11656

pgassmann avatar Jul 29 '23 18:07 pgassmann

Thanks for the pointers! I was about halfway through implementing contour lines in planetiler but ended up just porting the logic to JavaScript since it lets you generate any number of variations on thresholds from one dem source, and built that into maplibre-contour.

Let me know if people still have use cases for server-side generated hillshading/contour lines. Since maplibre now has client side support for those the biggest gap seems like server-generated global landcover.

msbarry avatar Jul 30 '23 00:07 msbarry

What would be amazing is if you could make a version of the javascript contour lines which works in aws lambda or cloudflare workers. Because I would love to use your contour lines in MapLibre Native but don't know how to get there...

wipfli avatar Jul 31 '23 12:07 wipfli

@wipfli Did you look at the Terradactile demo I linked above? This generates hillshade tiles on lambda. https://github.com/sparkgeo/terradactile-lambda/blob/master/terradactile/terradactile/app.py

I personally prefer provider-independent self-hosted services. For now I mostly played with tileserver-gl and styles.json to tweak and design map styles. I need to get more familiar with maplibre-gl-js and the plugins.

pgassmann avatar Aug 01 '23 09:08 pgassmann

Last year I wrote a script which I used to generate contour lines for the whole planet. https://github.com/CramericaIndustries/vector-terrain-cli

Downside of this script is that the contour lines are overlapping in the border areas of the DEM files. image

CramericaIndustries avatar Aug 01 '23 09:08 CramericaIndustries

Right now I am using the https://github.com/onthegomap/maplibre-contour posted above, which makes contour lines based on the terrain raster-dem.

heres a live example of that https://wifidb.net/demo/contours/contour_lines.html#15/32.24408/76.21147/0/60

The nice thing is this produces vector tile lines, which can be styled as you want. It also lets you adjust what levels you want to see without having to generate a whole new set of contour line tiles.

acalcutt avatar Oct 10 '23 13:10 acalcutt