Skip to main content

Neighbor DEM hillshade samples

Compute edge slopes across currently cached neighboring DEM tiles

Common hillshade layers now sample adjacent pixel centers from the same DEM source and current epoch. Available neighbor tiles or valid parent fallbacks provide cross-edge finite differences instead of repeating the current tile's edge height. X wraps at the date line; Y never wraps beyond the Mercator extent. Different pixel dimensions are resampled bilinearly in normalized tile coordinates.

map.addSource('dem', {
  type: 'raster-dem', tiles: ['https://your-dem.example/{z}/{x}/{y}.png'],
  tileSize: 256, encoding: 'mapbox'
});
map.addLayer({id: 'shading', type: 'hillshade', source: 'dem',
  paint: {'hillshade-illumination-anchor': 'map'}});
await map.sqs.flush({render: true});

Replace the address with DEM data you are authorized to use. demNeighborHillshade is true when the shared implementation is connected. Native libraries, WASM, main thread/Worker and desktop common layers use the same calculations; callers provide their own UI.

Missing valid neighbor samples preserve one-sided slopes. No extra neighbor downloads or invented zero heights are added. A NoData center remains transparent, interior NoData retains center substitution, and outside NoData behaves as a missing neighbor. Old epochs never contribute. Neighbor arrival/update refreshes derived versions and textures.

This stage improves derived hillshade only. Original DEM data, color-relief, elevation queries and 3D meshes are unchanged. Mesh seams, cross-LOD/level blending, full multidirectional lighting, device acceptance and formal releases remain separate tasks.

Generated4×4 step DEMs exaggerate the edge slope for six common script checks and actual pixel verification; they are not real elevation data. Script, fixture. Models cover the date line, missing/stale/NoData samples, different dimensions and valid parent fallbacks.