Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate contour lines from raster-dem source #5844

Open
mollymerp opened this issue Dec 12, 2017 · 9 comments
Open

Generate contour lines from raster-dem source #5844

mollymerp opened this issue Dec 12, 2017 · 9 comments
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏 needs discussion 💬

Comments

@mollymerp
Copy link
Contributor

mollymerp commented Dec 12, 2017

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

@mollymerp mollymerp added cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏 needs discussion 💬 labels Dec 12, 2017
@stevage
Copy link
Contributor

stevage commented Dec 12, 2017

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

@averas
Copy link
Contributor

averas commented Dec 18, 2017

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

@Scarysize
Copy link

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

@mollymerp
Copy link
Contributor Author

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

@bcbeta
Copy link

bcbeta commented Aug 6, 2018

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

@mb12
Copy link

mb12 commented Aug 6, 2018

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

@marcofugaro
Copy link

@agdhruv
Copy link

agdhruv commented Apr 21, 2021

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

@Scarysize How do you serve vector tiles? I have thousands of contour GeoJSONs (generated using d3-contour) which need to be displayed as and when the user requests them. I don't think sending the entire requested GeoJSON is the best option. Instead, I want to fetch vector tiles as and when the user pans/zooms. How do I convert GeoJSON into zoom/x/y indexed vector tiles? Or is there another better way to do this?

@stevage
Copy link
Contributor

stevage commented Apr 21, 2021

@agdhruv Typically, you use a tool like tippecanoe or GDAL to generate the vector tools, then serve them with something like tessera or tegola.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏 needs discussion 💬
Projects
None yet
Development

No branches or pull requests

8 participants