utils-hillshadeRgb.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import ee
  2. from ee_plugin import Map
  3. from ee_plugin.contrib import utils, palettes
  4. dem = ee.Image("AHN/AHN2_05M_RUW") \
  5. .resample('bicubic') \
  6. .focal_max(0.5, 'circle', 'meters') \
  7. .convolve(ee.Kernel.gaussian(0.5, 0.25, 'meters'))
  8. # See https://github.com/gee-community/ee-palettes
  9. # for the full list of supported color palettes
  10. # palette = palettes.crameri['lisbon'][50]
  11. palette = palettes.crameri['oleron'][50]
  12. # palette = palettes.crameri['roma'][50][::-1] # reversed
  13. # palette = palettes.crameri['batlow'][50]
  14. demRGB = dem.visualize(**{ 'min': -5, 'max': 5, 'palette': palette })
  15. Map.addLayer(demRGB , {}, 'DEM (RGB)', True)
  16. weight = 0.5 # hillshade vs RGB intensity (0 - flat, 1 - HS)
  17. exaggeration = 3 # vertical exaggeration
  18. azimuth = 300 # Sun azimuth
  19. zenith = 25 # Sun elevation
  20. brightness = -0.05 # 0 - default
  21. contrast = 0.05 # 0 - default
  22. saturation = 0.8 # 1 - default
  23. castShadows = False
  24. # no shadows
  25. rgb = utils.hillshadeRGB(demRGB, dem, weight, exaggeration,
  26. azimuth, zenith, contrast, brightness, saturation, castShadows)
  27. Map.addLayer(rgb, {}, 'DEM (hillshade)', False)
  28. # with shadows
  29. castShadows = True
  30. rgb = utils.hillshadeRGB(demRGB, dem, weight, exaggeration,
  31. azimuth, zenith, contrast, brightness, saturation, castShadows)
  32. Map.addLayer(rgb, {}, 'DEM (hillshade, shadows)', False)
  33. Map.setCenter(4.407, 52.177, 18)