hyperknot / openfreemap

Free and open-source map hosting solution with custom styles for websites and apps, using OpenStreetMap data
https://openfreemap.org/
Other
939 stars 14 forks source link

Terrain tiles / hillshading #19

Open hyperknot opened 2 hours ago

hyperknot commented 2 hours ago

This is a longer term research issue about terrain tiles. Since I've never worked with terrain tiles, and also don't know which open data sources are available, please contribute your knowledge if you have experience in working with them.

Long term aim would be to have a nice looking terrain map styles, like Google Maps has.

image

hyperknot commented 2 hours ago

Original discussion started by @aschleck here https://github.com/hyperknot/openfreemap/discussions/15

aschleck commented 2 hours ago

Raw source datasets I'm aware of:

3DEP is the most accurate but it's very very very large and hard to process, and only in the US. Most RGB DEM tilesets use NASADEM, but I think Copernicus is slightly better (research indicates it's a toss up https://www.tandfonline.com/doi/full/10.1080/10095020.2023.2296010#d1e321 https://www.usgs.gov/publications/evaluation-copernicus-dem-and-comparison-dem-used-landsat-collection-2-processing). In zxy tiling schemes most of the Arctic gets warped and no one generally cares about elevation at the south pole, so I ignored that. ASTER just seemed bad but maybe that's unfair.

I'm not a GIS expert by any means so would be happy to be corrected. https://www.maptiler.com/terrain// covers a lot of high level stuff if that's helpful.

aschleck commented 2 hours ago

(copying reply from the discussion)

I assume by terrain RGB you mean DEMs (digital elevation maps). In those layers you have a mapping from pixel to latlng where the value of the pixel encodes the elevation (note that with TIFF images you can do single channel 32-bit float values so it's not 3 channel RGB). My layers are generated from DEMs, though the tiling scheme for the source data I'm using (mostly Copernicus from the EU, some NASADEM) is not the standard zxy scheme so they are different.

I was separately working on generating a global zxy RGB DEM tileset but ran out of energy because I didn't desperately need it and the tooling I was using was being stupid.

There are very clever client side implementations that can generate contours (idk if they're vectorized, maybe) and hill shading rasters from zxy RGB DEMs at render time, however I decided to pregenerate them server side into actual tilesets. In my experience messing with hill shading, the gdal (the program I use to do the shading) implementation just looked visually better than the shader I wrote (my shader looked smoothed and weirdly shiny? gdal looks more real). Since I have implemented my own alternative to MapLibre it's possible that's just a flaw in my own code. Implementing contouring client side in my renderer seemed both too hard and also like an excellent way to crash mobile devices. Also my contour vector layer encodes when a contour is over a glacier (it's pretty!) and it's doable but bonus complexity to calculate that client side.

Not sure if I answered your question. I think it's good to have all three and I personally think they're orthogonal even though you can do everything from one DEM tileset at render time.

hyperknot commented 2 hours ago

Thanks a lot. I prefer to just collect options and information at the moment. You mentioned before that it's about 1.5 TB of data for contours and hillshades, I'm a bit worried it might not be possible to host this much easily.

I'm curious of what's possible by client generated solutions and when is it necessary to use server-generated tiles.

aschleck commented 2 hours ago

One last thought: my contours are 900gb but MapTiler's dataset is only 215gb. I think I looked into why and I can't recall if mine are denser, more accurate, or if MapTiler's engineers are smarter than me and found some 4x optimization I didn't see. You could compare them to see. So anyway depending on your goals and how much over-zooming you anticipate (for my usecase I expect significant over-zoom) you could reduce the storage size.

aschleck commented 24 minutes ago

https://github.com/onthegomap/maplibre-contour + https://registry.opendata.aws/terrain-tiles/

hyperknot commented 6 minutes ago

Thanks a lot @aschleck!

Actually maplibre-contour looks great! I mean you probably immediately recognise the differences between your server rendered version and the maplibre-contour, but it looks quite nice for me.

image