d.shade.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/usr/bin/env python
  2. ############################################################################
  3. #
  4. # MODULE: d.shade
  5. # AUTHOR(S): Unknown; updated to GRASS 5.7 by Michael Barton
  6. # Converted to Python by Glynn Clements
  7. # PURPOSE: Uses d.his to drape a color raster over a shaded relief map
  8. # COPYRIGHT: (C) 2004-2013 by the GRASS Development Team
  9. #
  10. # This program is free software under the GNU General Public
  11. # License (>=v2). Read the file COPYING that comes with GRASS
  12. # for details.
  13. #
  14. #############################################################################
  15. #%module
  16. #% description: Drapes a color raster over an shaded relief or aspect map.
  17. #% keyword: display
  18. #% keyword: elevation
  19. #% keyword: relief
  20. #% keyword: hillshade
  21. #% keyword: visualization
  22. #%end
  23. #%option G_OPT_R_INPUT
  24. #% key: shade
  25. #% description: Name of shaded relief or aspect raster map
  26. #%end
  27. #%option G_OPT_R_INPUT
  28. #% key: color
  29. #% label: Name of raster to drape over relief raster map
  30. #% description: Typically, this raster is elevation or other colorful raster
  31. #%end
  32. #%option
  33. #% key: brighten
  34. #% type: integer
  35. #% description: Percent to brighten
  36. #% options: -99-99
  37. #% answer: 0
  38. #%end
  39. from grass.script import core as gcore
  40. from grass.exceptions import CalledModuleError
  41. # i18N
  42. import os
  43. import gettext
  44. gettext.install('grassmods', os.path.join(os.getenv("GISBASE"), 'locale'))
  45. def main():
  46. options, unused = gcore.parser()
  47. drape_map = options['color']
  48. relief_map = options['shade']
  49. brighten = options['brighten']
  50. try:
  51. gcore.run_command('d.his', hue=drape_map, intensity=relief_map,
  52. brighten=brighten)
  53. except CalledModuleError:
  54. gcore.fatal(_("Module %s failed. Check the above error messages.") % 'd.his')
  55. if __name__ == "__main__":
  56. main()