g.gui.image2target.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #!/usr/bin/env python3
  2. ############################################################################
  3. #
  4. # MODULE: Create 3-Dimensional GCPs from elevation and target image
  5. # AUTHOR(S): Yann modified the code (was Markus Metz for the GCP manager)
  6. # PURPOSE: Georectification and Ground Control Points management for 3D correction.
  7. # COPYRIGHT: (C) 2012-2020 by Markus Metz, and the GRASS Development Team
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. ############################################################################
  20. #%module
  21. #% description: Georectifies a map and allows managing Ground Control Points for 3D correction.
  22. #% keyword: imagery
  23. #% keyword: GUI
  24. #% keyword: aerial
  25. #% keyword: photo
  26. #% keyword: georectification
  27. #% keyword: geometry
  28. #% keyword: GCP
  29. #%end
  30. ##%option G_OPT_M_LOCATION
  31. ##% key: source_location
  32. ##% label: The name of the source location (has no projection)
  33. ##% description: The name of the source location (has no projection)
  34. ###% section: source
  35. ##% required: yes
  36. ##%end
  37. ##%option G_OPT_M_MAPSET
  38. ##% key: source_mapset
  39. ##% label: The name of the source mapset (has no projection)
  40. ##% description: The name of the source mapset (has no projection)
  41. ###% section: source
  42. ##% required: yes
  43. ##%end
  44. ##%option G_OPT_I_GROUP
  45. ##% key: source_group
  46. ##% required: yes
  47. ##% section: source
  48. ##%end
  49. ##%option G_OPT_R_INPUT
  50. ##% key: source_image
  51. ##% required: yes
  52. ###% section: source
  53. ##%end
  54. ##%option G_OPT_R_INPUT
  55. ##% key: target_image
  56. ##% label: The name of the image that is already georeferenced used to find location of GCPs
  57. ##% description: The name of the image that is already georeferenced used to find the location of GCPs
  58. ###% section: target
  59. ##% required: no
  60. ##%end
  61. ##%option
  62. ##% key: camera
  63. ##% type: string
  64. ##% label: The name of the camera (generated in i.ortho.camera)
  65. ##% description: The name of the camera (generated in i.ortho.camera)
  66. ##% required: yes
  67. ###% section: parameters
  68. ##%end
  69. ##%option
  70. ##% key: order
  71. ##% type: string
  72. ##% label: The rectification order
  73. ##% description: The rectification order
  74. ##% required: yes
  75. ##% answer: 1
  76. ###% section: parameters
  77. ##%end
  78. ##%option
  79. ##% key: extension
  80. ##% type: string
  81. ##% label: The name of the output files extension
  82. ##% description: The name of the output files extension
  83. ##% required: yes
  84. ##% answer: _ii2t_out
  85. ##% section: target
  86. ##%end
  87. """
  88. Module to run GCP management tool as stadalone application.
  89. @author Vaclav Petras <wenzeslaus gmail.com> (standalone module)
  90. """
  91. import os
  92. import grass.script as gscript
  93. def main():
  94. """
  95. Sets the GRASS display driver
  96. """
  97. options, flags = gscript.parser()
  98. import wx
  99. from grass.script.setup import set_gui_path
  100. set_gui_path()
  101. from core.settings import UserSettings
  102. from core.giface import StandaloneGrassInterface
  103. from image2target.ii2t_manager import GCPWizard
  104. driver = UserSettings.Get(group="display", key="driver", subkey="type")
  105. if driver == "png":
  106. os.environ["GRASS_RENDER_IMMEDIATE"] = "png"
  107. else:
  108. os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"
  109. # if options['source_location']:
  110. # src_loc = options['source_location']
  111. # else:
  112. # gscript.fatal(_("No georeferenced source location provided"))
  113. # if options['source_mapset']:
  114. # src_mpt = options['source_mapset']
  115. # else:
  116. # gscript.fatal(_("No georeferenced source mapset provided"))
  117. # if options['source_group']:
  118. # src_grp = options['source_group']
  119. # else:
  120. # gscript.fatal(_("Please provide a source group name to process"))
  121. # if options['source_image']:
  122. # src_ras = options['source_image']
  123. # else:
  124. # gscript.fatal(_("Please provide a source image map name to process"))
  125. # if options['target_image']:
  126. # tgt_ras = options['target_image']
  127. # else:
  128. # gscript.fatal(_("No georeferenced target map provided"))
  129. # if options['camera']:
  130. # camera = options['camera']
  131. # else:
  132. # gscript.fatal(_("Please provide a camera name (generated by i.ortho.camera)"))
  133. # if options['order']:
  134. # order = options['order']
  135. # else:
  136. # gscript.fatal(_("Please provive an order value"))
  137. # if options['extension']:
  138. # extension = options['extension']
  139. # else:
  140. # gscript.fatal(_("Please provide an output file extension"))
  141. app = wx.App()
  142. # wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface(),
  143. # srcloc=src_loc,srcmpt=src_mpt,srcgrp=src_grp,srcras=src_ras,
  144. # tgtras=tgt_ras,camera=camera, order=order, extension=extension)
  145. wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface())
  146. app.MainLoop()
  147. if __name__ == "__main__":
  148. main()