onthegomap / planetiler

Flexible tool to build planet-scale vector tilesets from OpenStreetMap data fast
Apache License 2.0
1.34k stars 107 forks source link

[FEATURE] contour lines #12

Open markuman opened 2 years ago

markuman commented 2 years ago

I'd like to add contour lines.

msbarry commented 2 years ago

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?

markuman commented 2 years ago

Do you have any background knowledge on generating contour lines?

Unfortunately not.

msbarry commented 2 years ago

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-

pgassmann commented 1 year ago

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

Free terrain tiles from aws:

Terrain Tiles:

Generate hillshade

Generate contours

pgassmann commented 1 year ago

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

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

msbarry commented 1 year ago

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.

wipfli commented 1 year ago

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

pgassmann commented 1 year ago

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

CramericaIndustries commented 1 year ago

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

acalcutt commented 11 months ago

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.