g.gui.image2target.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #!/usr/bin/env python
  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-2017 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: aerial
  24. #% keyword: photo
  25. #% keyword: georectification
  26. #% keyword: GCP
  27. #% keyword: GUI
  28. #%end
  29. ##%option G_OPT_M_LOCATION
  30. ##% key: source_location
  31. ##% label: The name of the source location (has no projection)
  32. ##% description: The name of the source location (has no projection)
  33. ###% section: source
  34. ##% required: yes
  35. ##%end
  36. ##%option G_OPT_M_MAPSET
  37. ##% key: source_mapset
  38. ##% label: The name of the source mapset (has no projection)
  39. ##% description: The name of the source mapset (has no projection)
  40. ###% section: source
  41. ##% required: yes
  42. ##%end
  43. ##%option G_OPT_I_GROUP
  44. ##% key: source_group
  45. ##% required: yes
  46. ##% section: source
  47. ##%end
  48. ##%option G_OPT_R_INPUT
  49. ##% key: source_image
  50. ##% required: yes
  51. ###% section: source
  52. ##%end
  53. ##%option G_OPT_R_INPUT
  54. ##% key: target_image
  55. ##% label: The name of the image that is already georeferenced used to find location of GCPs
  56. ##% description: The name of the image that is already georeferenced used to find the location of GCPs
  57. ###% section: target
  58. ##% required: no
  59. ##%end
  60. ##%option
  61. ##% key: camera
  62. ##% type: string
  63. ##% label: The name of the camera (generated in i.ortho.camera)
  64. ##% description: The name of the camera (generated in i.ortho.camera)
  65. ##% required: yes
  66. ###% section: parameters
  67. ##%end
  68. ##%option
  69. ##% key: order
  70. ##% type: string
  71. ##% label: The rectification order
  72. ##% description: The rectification order
  73. ##% required: yes
  74. ##% answer: 1
  75. ###% section: parameters
  76. ##%end
  77. ##%option
  78. ##% key: extension
  79. ##% type: string
  80. ##% label: The name of the output files extension
  81. ##% description: The name of the output files extension
  82. ##% required: yes
  83. ##% answer: _ii2t_out
  84. ##% section: target
  85. ##%end
  86. """
  87. Module to run GCP management tool as stadalone application.
  88. @author Vaclav Petras <wenzeslaus gmail.com> (standalone module)
  89. """
  90. import os
  91. import grass.script as gscript
  92. def main():
  93. """
  94. Sets the GRASS display driver
  95. """
  96. options, flags = gscript.parser()
  97. import wx
  98. from grass.script.setup import set_gui_path
  99. set_gui_path()
  100. from core.settings import UserSettings
  101. from core.globalvar import CheckWxVersion
  102. from core.giface import StandaloneGrassInterface
  103. from iimage2target.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. if not CheckWxVersion([2, 9]):
  143. wx.InitAllImageHandlers()
  144. # wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface(),
  145. # srcloc=src_loc,srcmpt=src_mpt,srcgrp=src_grp,srcras=src_ras,
  146. # tgtras=tgt_ras,camera=camera, order=order, extension=extension)
  147. wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface())
  148. app.MainLoop()
  149. if __name__ == '__main__':
  150. main()