d.what.rast.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python
  2. ############################################################################
  3. #
  4. # MODULE: d.what.rast
  5. # AUTHOR(S): Anna Petrasova <kratochanna gmail.com>
  6. # PURPOSE: Script for querying raster maps in d.mon
  7. # COPYRIGHT: (C) 2014 by the GRASS Development Team
  8. #
  9. # This program is free software under the GNU General
  10. # Public License (>=v2). Read the file COPYING that
  11. # comes with GRASS for details.
  12. #
  13. #############################################################################
  14. #%module
  15. #% description: Allows the user to interactively query raster map layers at user-selected locations.
  16. #% keywords: display
  17. #% keywords: vector
  18. #%end
  19. #%option G_OPT_R_INPUTS
  20. #% key: map
  21. #%end
  22. from grass.script import core as gcore
  23. def main():
  24. options, flags = gcore.parser()
  25. gisenv = gcore.gisenv()
  26. if 'MONITOR' in gisenv:
  27. cmd_file = gisenv['MONITOR_{monitor}_CMDFILE'.format(monitor=gisenv['MONITOR'].upper())]
  28. dout_cmd = 'd.what.rast'
  29. for param, val in options.iteritems():
  30. if val:
  31. dout_cmd += " {param}={val}".format(param=param, val=val)
  32. with open(cmd_file, "a") as file_:
  33. file_.write(dout_cmd)
  34. else:
  35. gcore.fatal(_("No graphics device selected. Use d.mon to select graphics device."))
  36. if __name__ == "__main__":
  37. main()