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

Design proposal: enhancements ro raster-dem to improve hillshade and shaded-relief #338

Open
dBitech opened this issue Sep 13, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@dBitech
Copy link

dBitech commented Sep 13, 2023

User Story

Currently, vector styling of dem data is somewhat limited, meaning most of my base layer work needs to be done as pre-styled rasters. This reduces the usefulness of what I can provide to mobile users in offline modes.

Rationale

There are some very good example write-ups on doing more advanced shaded relief using GDAL, and as shown in the following tutorial Intro to GDAL: part 5 shaded relief It would be great if we could offer this kind of shaded- relief directly within maplibre. If we start with the aspect mode, we could quickly realize Swiss Style Relief Shading which was brought to life by Eduard Imhof. Further modes like Slope could be used to help visually highlight areras that could be of intrest to a number of market segments, from Recreational Maps users such as Hiking and Skiing to areas of risk assessment related to Avalanches and Landslides.

Impact

@HarelM HarelM transferred this issue from maplibre/maplibre-gl-js Sep 17, 2023
@HarelM
Copy link
Member

HarelM commented Sep 17, 2023

I would recommend defining exactly which parameters in the style definition would allow this.
The current definition is a bit vague unfortunately.

@dBitech
Copy link
Author

dBitech commented Sep 21, 2023

For aspect, my thought would as a start be an array under paint such as: aspect-color: [ [degree, rgba], [degree, rgba], [degree, rgba],...]

my though this would be a paint-property on the hillshade style layer

So that would look like:

...
layers: [
  {
    id: 'shaded-releif',
    type: 'hillshade',
    source: 'hillshadesource',
    layout: {visibility: 'visible'},
    paint: {'aspect-color':
      [
          [0, rgba(243,241,231,1)],
          [22.5, rgba(242,241,235,1)],
          [45, rgba(241,241,2390,1)],
          [67.5, rgba(240,241,243,1)],
          [90, rgba(239,241,246,1)],
          [112.5, rgba(238,240,250,1)],
          [135, rgba(236,240,254,1)],
          [157.5, rgba(238,240,250,1)],
          [180, rgba(239,241,246,1)],
          [202.5, rgba(240,241,243,1)],
          [225, rgba(241,241,239,1)],
          [247.5, rgba(242,241,235,1)],
          [270, rgba(243,241,231,1)],
          [292.5, rgba(245,241,227,1)],
          [315, rgba(246,241,222,1)],
          [337.5, rgba(245,241,227,1)],
          [359.999, rgba(243,241,231,1)]
      ]
    }
  },
...

resulting in a hillshade that is colored based on the aspect of the slope.
image

(Images courtesy of Robert Simmon's Intro to GDAL: part 5 shaded relief

@HarelM
Copy link
Member

HarelM commented Sep 27, 2023

I'm not sure I understand your last comment can you elaborate?
How would the style spec look after this change and what would the tiles look like on the map?
See also the following discussion, which might be somewhat related:
maplibre/maplibre-gl-js#3109

@dBitech
Copy link
Author

dBitech commented Oct 26, 2023

Once we have supporting code for aspect, then adding multi-direction lighting support would become fairly trivial. (note that maplibre uses 335 as the default illumination direction vs the 315 in the publication), this functionality would produce hillshade similar to gdaldem's multidirectional hillshade mode.

...
layers: [
  {
    id: 'shaded-releif',
    type: 'hillshade',
    source: 'hillshadesource',
    layout: {visibility: 'visible'},
    paint: {'hillshade-multidirection': true }
 }
],
...

In the event that hillshade-illumination-direction was specified then the multi-direction weighting would be centered around the provided direction

@HarelM
Copy link
Member

HarelM commented Oct 31, 2023

It's says 335 in the docs:
image

I'm not sure I fully understand the definition or how would this affect.
I would recommend bringing this to the monthly meeting and present it there.
Meetings invite are sent in our slack channel.

@HarelM HarelM changed the title enhancements ro raster-dem to improve hillshade and shaded-relief Design proposal: enhancements ro raster-dem to improve hillshade and shaded-relief Dec 31, 2023
@HarelM HarelM added the enhancement New feature or request label Dec 31, 2023
@dBitech
Copy link
Author

dBitech commented Jan 10, 2024

There would be no change to the existing functionality with respect to hillshade-illumination-direction, but in the event it was specified along with paint: {'hillshade-multidirection': true } then the offsets used to create the multi-direction lighting would use the hillshade-illumination-direction as it's primary lighting direction, rotating the other light sources relitive to this direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants