Mapbox-gl-js: Generate contour lines from raster-dem source

Created on 12 Dec 2017  路  7Comments  路  Source: mapbox/mapbox-gl-js

Cutting this ticket to start a conversation about whether we want to extend the raster-dem source to support contour line generation. I have not started exploring the feasibility of this from a performance standpoint.

I'm not sure how many users would be interested in having configurable contour lines, so if this is something you would use please 馃憤 this ticket 馃檭 .

There is probably a way to do this that I haven't thought of, but the most straightforward method I can think of would be doing a precalculation/Framebuffer pass similar to the hillshade layer that calculates the contours and outputs a new texture with the contour lines encoded which is what is rendered to the map. Making sure the contours line up between tiles would probably be tricky...

cc @mapbox/cartography-cats

cross-platform feature needs discussion

Most helpful comment

I have quite some experience in this area. I'm generating interpolated DEMs and subsequent contour lines offline today, but store them as vector data and serve them to Mapbox GL JS via vector tiles. You can get a feeling for this at https://fishlr.com/29381881-22dd-46da-b3ad-2d561873117a and at https://www.youtube.com/watch?v=Sk3jinu_oD8

I also generate offline maps for download using the node bindings:

Norasj枚n

I even generate and serve my own RGB based DEMs (which I came up with before Mapbox started using the concept .. :-)) which allows me do do stuff like https://www.youtube.com/watch?v=GYfkZNuyCJE (the plotter is fake, and based on DEM data from RGB-raster tiles).

All 7 comments

Generating contours in the browser? Wow. I had never even considered that possibility. Hmm..

I think this person might like it: https://stackoverflow.com/questions/47434279/how-to-create-contour-heat-map-mapbox

I have quite some experience in this area. I'm generating interpolated DEMs and subsequent contour lines offline today, but store them as vector data and serve them to Mapbox GL JS via vector tiles. You can get a feeling for this at https://fishlr.com/29381881-22dd-46da-b3ad-2d561873117a and at https://www.youtube.com/watch?v=Sk3jinu_oD8

I also generate offline maps for download using the node bindings:

Norasj枚n

I even generate and serve my own RGB based DEMs (which I came up with before Mapbox started using the concept .. :-)) which allows me do do stuff like https://www.youtube.com/watch?v=GYfkZNuyCJE (the plotter is fake, and based on DEM data from RGB-raster tiles).

All for it! We experimented with client-side generation using the canvas 2D API and the marching squares algorithm for conturing. Then extracting the contours and rendering them as GeoJSON:

image

Though we couldn't really get on par with line smoothing and other improvements you can easily do offline. Now we just serve vector tiles:

image

thanks for sharing your past work on this @stevage @averas!

This guy seems to have figured it out?
https://www.axismaps.com/blog/2018/04/contours-in-browser/

@averas Is this data publicly available for Sweden? For US, we have very good public data for coastal waterways and Great Lakes but not a whole lot for inland lakes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jfirebaugh picture jfirebaugh  路  3Comments

samanpwbb picture samanpwbb  路  3Comments

aderaaij picture aderaaij  路  3Comments

yoursweater picture yoursweater  路  3Comments

rigoneri picture rigoneri  路  3Comments