r.plus.example.py 707 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python
  2. #%module
  3. #% description: Adds the values of two rasters (A + B)
  4. #% keyword: raster
  5. #% keyword: algebra
  6. #% keyword: sum
  7. #%end
  8. #%option G_OPT_R_INPUT
  9. #% key: araster
  10. #% description: Name of input raster A in an expression A + B
  11. #%end
  12. #%option G_OPT_R_INPUT
  13. #% key: braster
  14. #% description: Name of input raster B in an expression A + B
  15. #%end
  16. #%option G_OPT_R_OUTPUT
  17. #%end
  18. import grass.script as gscript
  19. def main():
  20. options, flags = gscript.parser()
  21. araster = options['araster']
  22. braster = options['braster']
  23. output = options['output']
  24. gscript.mapcalc('{r} = {a} + {b}'.format(r=output, a=araster, b=braster))
  25. return 0
  26. if __name__ == "__main__":
  27. main()