i.band.library.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/env python3
  2. ############################################################################
  3. #
  4. # MODULE: i.band.library
  5. # AUTHOR(S): Martin Landa <landa.martin gmail com>
  6. #
  7. # PURPOSE: Prints available semantic label information used for multispectral data.
  8. #
  9. # COPYRIGHT: (C) 2019 by mundialis GmbH & Co.KG, and the GRASS Development Team
  10. #
  11. # This program is free software under the GNU General
  12. # Public License (>=v2). Read the file COPYING that
  13. # comes with GRASS for details.
  14. #
  15. #############################################################################
  16. # %module
  17. # % description: Prints available semantic label information used for multispectral data.
  18. # % keyword: general
  19. # % keyword: imagery
  20. # % keyword: semantic label
  21. # % keyword: image collections
  22. # %end
  23. # %option
  24. # % key: pattern
  25. # % type: string
  26. # % description: Semantic label search pattern (examples: L, S2, .*_2, S2_1)
  27. # % required: no
  28. # % multiple: no
  29. # %end
  30. # %option
  31. # % key: operation
  32. # % type: string
  33. # % required: no
  34. # % multiple: no
  35. # % options: print
  36. # % description: Operation to be performed
  37. # % answer: print
  38. # %end
  39. # %flag
  40. # % key: e
  41. # % description: Print extended metadata information
  42. # %end
  43. import sys
  44. import grass.script as gs
  45. def main():
  46. from grass.semantic_label import SemanticLabelReader, SemanticLabelReaderError
  47. kwargs = {}
  48. if "," in options["pattern"]:
  49. gs.fatal("Multiple values not supported")
  50. kwargs["semantic_label"] = options["pattern"]
  51. kwargs["extended"] = flags["e"]
  52. if options["operation"] == "print":
  53. try:
  54. reader = SemanticLabelReader()
  55. reader.print_info(**kwargs)
  56. except SemanticLabelReaderError as e:
  57. gs.fatal(e)
  58. return 0
  59. if __name__ == "__main__":
  60. options, flags = gs.parser()
  61. sys.exit(main())