def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.utils import _ from dbmgr.manager import AttributeManager mapName = gscript.find_file(options['map'], element='vector')['fullname'] if not mapName: gscript.set_raise_on_error(False) gscript.fatal(_("Vector map <%s> not found") % options['map']) app = wx.App() gscript.message(_("Loading attribute data for vector map <%s>...") % mapName) f = AttributeManager(parent=None, id=wx.ID_ANY, title="%s - <%s>" % (_("GRASS GIS Attribute Table Manager"), mapName), size=(900, 600), vectorName=mapName) f.Show() app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() try: from timeline.frame import TimelineFrame except ImportError as e: # TODO: why do we need this special check here, the reason of error # is wrong intallation or something, no need to report this to the # user in a nice way gscript.fatal(e.message) datasets = options['inputs'].strip().split(',') datasets = [data for data in datasets if data] view3d = flags['3'] app = wx.App() frame = TimelineFrame(None) frame.SetDatasets(datasets) frame.Show3D(view3d) frame.Show() app.MainLoop()
def main(): """Sets the GRASS display driver .. todo:: use command line options as an alternative to wizard """ options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from core.globalvar import CheckWxVersion from core.giface import StandaloneGrassInterface from gcp.manager import GCPWizard driver = UserSettings.Get(group="display", key="driver", subkey="type") if driver == "png": os.environ["GRASS_RENDER_IMMEDIATE"] = "png" else: os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo" app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface()) app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.utils import _ from dbmgr.manager import AttributeManager mapName = gscript.find_file(options['map'], element='vector')['fullname'] if not mapName: gscript.set_raise_on_error(False) gscript.fatal(_("Vector map <%s> not found") % options['map']) app = wx.App() gscript.message( _("Loading attribute data for vector map <%s>...") % mapName) f = AttributeManager(parent=None, id=wx.ID_ANY, title="%s - <%s>" % (_("GRASS GIS Attribute Table Manager"), mapName), size=(900, 600), vectorName=mapName) f.Show() app.MainLoop()
def main(): """Sets the GRASS display driver .. todo:: use command line options as an alternative to wizard """ options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from core.globalvar import CheckWxVersion from core.giface import StandaloneGrassInterface from gcp.manager import GCPWizard driver = UserSettings.Get(group='display', key='driver', subkey='type') if driver == 'png': os.environ['GRASS_RENDER_IMMEDIATE'] = 'png' else: os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo' app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface()) app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() try: from timeline.frame import TimelineFrame except ImportError as e: # TODO: why do we need this special check here, the reason of error # is wrong intallation or something, no need to report this to the # user in a nice way gscript.fatal(str(e)) datasets = options['inputs'].strip().split(',') datasets = [data for data in datasets if data] view3d = flags['3'] app = wx.App() frame = TimelineFrame(None) frame.SetDatasets(datasets) frame.Show3D(view3d) frame.Show() app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from dbmgr.manager import AttributeManager mapName = gscript.find_file(options["map"], element="vector")["fullname"] if not mapName: gscript.set_raise_on_error(False) gscript.fatal(_("Vector map <%s> not found") % options["map"]) app = wx.App() gscript.message( _("Loading attribute data for vector map <%s>...") % mapName) f = AttributeManager( parent=None, id=wx.ID_ANY, base_title=_("Attribute Table Manager - GRASS GIS"), size=(900, 600), vectorName=mapName, ) f.Show() app.MainLoop()
def main(): """Sets the GRASS display driver .. todo:: use command line options as an alternative to wizard """ options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from core.giface import StandaloneGrassInterface from gcp.manager import GCPWizard driver = UserSettings.Get(group="display", key="driver", subkey="type") if driver == "png": os.environ["GRASS_RENDER_IMMEDIATE"] = "png" else: os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo" app = wx.App() wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface()) app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.utils import _ from core.giface import StandaloneGrassInterface try: from tplot.frame import TplotFrame except ImportError as e: gscript.fatal(e.message) rasters = None if options['strds']: rasters = options['strds'].strip().split(',') coords = None if options['coordinates']: coords = options['coordinates'].strip().split(',') cats = None if options['cats']: cats = options['cats'] output = options['output'] vectors = None attr = None if options['stvds']: vectors = options['stvds'].strip().split(',') if not options['attr']: gscript.fatal(_("With stvds you have to set 'attr' option")) else: attr = options['attr'] if coords and cats: gscript.fatal( _("With stvds it is not possible to use 'coordinates' " "and 'cats' options together")) elif not coords and not cats: gscript.warning( _("With stvds you have to use 'coordinates' or " "'cats' option")) app = wx.App() frame = TplotFrame(parent=None, giface=StandaloneGrassInterface()) frame.SetDatasets(rasters, vectors, coords, cats, attr) if output: frame.OnRedraw() if options['size']: sizes = options['size'].strip().split(',') sizes = [int(s) for s in sizes] frame.canvas.SetSize(sizes) if output.split('.')[-1].lower() == 'png': frame.canvas.print_png(output) if output.split('.')[-1].lower() in ['jpg', 'jpeg']: frame.canvas.print_jpg(output) if output.split('.')[-1].lower() in ['tif', 'tiff']: frame.canvas.print_tif(output) else: frame.Show() app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.utils import _ from core.giface import StandaloneGrassInterface try: from tplot.frame import TplotFrame except ImportError as e: gscript.fatal(e.message) rasters = None if options['strds']: rasters = options['strds'].strip().split(',') coords = None if options['coordinates']: coords = options['coordinates'].strip().split(',') cats = None if options['cats']: cats = options['cats'] output = options['output'] vectors = None attr = None if options['stvds']: vectors = options['stvds'].strip().split(',') if not options['attr']: gscript.fatal(_("With stvds you have to set 'attr' option")) else: attr = options['attr'] if coords and cats: gscript.fatal(_("With stvds it is not possible to use 'coordinates' " "and 'cats' options together")) elif not coords and not cats: gscript.warning(_("With stvds you have to use 'coordinates' or " "'cats' option")) app = wx.App() frame = TplotFrame(parent=None, giface=StandaloneGrassInterface()) frame.SetDatasets(rasters, vectors, coords, cats, attr) if output: frame.OnRedraw() if options['size']: sizes = options['size'].strip().split(',') sizes = [int(s) for s in sizes] frame.canvas.SetSize(sizes) if output.split('.')[-1].lower() == 'png': frame.canvas.print_png(output) if output.split('.')[-1].lower() in ['jpg', 'jpeg']: frame.canvas.print_jpg(output) if output.split('.')[-1].lower() in ['tif', 'tiff']: frame.canvas.print_tif(output) else: frame.Show() app.MainLoop()
def __init__(self, map, type): try: global CI_Date, CI_OnlineResource, CI_ResponsibleParty, \ DQ_DataQuality, Environment, etree, EX_Extent, \ EX_GeographicBoundingBox, FileSystemLoader, MD_Distribution, \ MD_ReferenceSystem, RunCommand from owslib.iso import ( CI_Date, CI_OnlineResource, CI_ResponsibleParty, DQ_DataQuality, EX_Extent, EX_GeographicBoundingBox, MD_Distribution, MD_ReferenceSystem, ) from jinja2 import Environment, FileSystemLoader from lxml import etree set_gui_path() from core.gcmd import RunCommand except ModuleNotFoundError as e: msg = e.msg sys.exit( globalvar.MODULE_NOT_FOUND.format(lib=msg.split("'")[-2], url=globalvar.MODULE_URL)) self.map = map self.type = type # function to check if map exist self.md_grass = {} self.md_abstract = '' self.md_vinfo_h = '' # v.info flag=h" - parse self.gisenv_grass = grass.gisenv() # dict with gisenv information # suffix of output xml file (variables) self.schema_type = '_basic.xml' self.profileName = 'GRASS BASIC' context = mdutil.StaticContext() self.dirpath = os.path.join(context.lib_path, 'profiles') # metadata object from OWSLIB ( for define md values) self.md = mdutil.MD_MetadataMOD(md=None) self.profilePath = None # path to file with xml templates if self.type == "raster": self.isMapExist() self.parseRast() elif self.type == "vector": self.isMapExist() self.parseVect() elif self.type == "r3??": # TODO self.parseRast3D() elif self.type == 'strds' or self.type == 'stvds': self.parseTemporal()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from core.giface import StandaloneGrassInterface from core import globalvar from mapswipe.frame import SwipeMapDisplay driver = UserSettings.Get(group="display", key="driver", subkey="type") if driver == "png": os.environ["GRASS_RENDER_IMMEDIATE"] = "png" else: os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo" first = options["first"] second = options["second"] mode = options["mode"] for mapName in [first, second]: if mapName: gfile = gscript.find_file(name=mapName) if not gfile["name"]: gscript.fatal(_("Raster map <%s> not found") % mapName) app = wx.App() # show main frame frame = wx.Frame( parent=None, size=globalvar.MAP_WINDOW_SIZE, title=_("Map Swipe Tool - GRASS GIS"), ) frame = SwipeMapDisplay( parent=frame, giface=StandaloneGrassInterface(), ) if first: frame.SetFirstRaster(first) if second: frame.SetSecondRaster(second) if first or second: frame.SetRasterNames() frame.SetViewMode(mode) frame.Show() app.MainLoop()
def main(): """Sets the GRASS display driver """ options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from core.globalvar import CheckWxVersion from core.giface import StandaloneGrassInterface from photo2image.ip2i_manager import GCPWizard driver = UserSettings.Get(group='display', key='driver', subkey='type') if driver == 'png': os.environ['GRASS_RENDER_IMMEDIATE'] = 'png' else: os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo' if options['group']: group = options['group'] else: gscript.fatal(_("Please provide a group name to process")) if options['raster']: raster = options['raster'] else: gscript.fatal(_("Please provide a raster map name to process")) if options['camera']: camera = options['camera'] else: gscript.fatal(_("Please provide a camera name (generated by i.ortho.camera)")) if options['order']: order = options['order'] else: gscript.fatal(_("Please provive an order value (1 if 4 Fiducials, 2 if 8 Fiducials)")) if options['extension']: extension = options['extension'] else: gscript.fatal(_("Please provive an output files extension (used by i.rectify)")) app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface(), group=group, raster=raster, raster1=raster, camera=camera, order=order, extension=extension) app.MainLoop()
def main(): options, flags = gcore.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.globalvar import CheckWxVersion, MAP_WINDOW_SIZE from core.giface import StandaloneGrassInterface from core.settings import UserSettings from example.frame import ExampleMapDisplay if options["input"]: map_name = gcore.find_file(name=options["input"], element="cell")["fullname"] if not map_name: gcore.fatal( _("Raster map <{raster}> not found").format( raster=options["input"])) # define display driver (avoid 'no graphics device selected' error at start up) driver = UserSettings.Get(group="display", key="driver", subkey="type") if driver == "png": os.environ["GRASS_RENDER_IMMEDIATE"] = "png" else: os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo" # launch application app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() # show main frame frame = wx.Frame(parent=None, size=MAP_WINDOW_SIZE, title=_("Example Tool - GRASSGIS")) frame = ExampleMapDisplay( parent=frame, giface=StandaloneGrassInterface(), ) if options["input"]: frame.giface.WriteLog( _("Loading raster map <{raster}>...").format(raster=map_name)) frame.SetLayer(map_name) frame.Show() app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from core.globalvar import CheckWxVersion from core.giface import StandaloneGrassInterface from core.utils import _ from mapswipe.frame import SwipeMapFrame driver = UserSettings.Get(group='display', key='driver', subkey='type') if driver == 'png': os.environ['GRASS_RENDER_IMMEDIATE'] = 'png' else: os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo' first = options['first'] second = options['second'] mode = options['mode'] for mapName in [first, second]: if mapName: gfile = gscript.find_file(name=mapName) if not gfile['name']: gscript.fatal(_("Raster map <%s> not found") % mapName) app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() frame = SwipeMapFrame(parent=None, giface=StandaloneGrassInterface()) if first: frame.SetFirstRaster(first) if second: frame.SetSecondRaster(second) if first or second: frame.SetRasterNames() frame.SetViewMode(mode) frame.Show() app.MainLoop()
def main(): gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.giface import StandaloneGrassInterface from rlisetup.frame import RLiSetupFrame app = wx.App() frame = RLiSetupFrame(parent=None, giface=StandaloneGrassInterface()) frame.Show() frame.CenterOnScreen() app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from psmap.frame import PsMapFrame app = wx.App() frame = PsMapFrame(parent=None) frame.Show() if options['file']: frame.LoadFile(options['file']) app.MainLoop()
def main(): options, flags = gscript.parser() # import wx only after running parser # to avoid issues when only interface is needed import wx from grass.script.setup import set_gui_path set_gui_path() from core.giface import StandaloneGrassInterface from datacatalog.frame import DataCatalogFrame app = wx.App() frame = DataCatalogFrame(parent=None, giface=StandaloneGrassInterface()) frame.CentreOnScreen() frame.Show() app.MainLoop()
def main(): gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.giface import StandaloneGrassInterface from core.globalvar import CheckWxVersion from rlisetup.frame import RLiSetupFrame app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() frame = RLiSetupFrame(parent=None, giface=StandaloneGrassInterface()) frame.Show() frame.CenterOnScreen() app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.globalvar import CheckWxVersion from psmap.frame import PsMapFrame app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() frame = PsMapFrame(parent=None) frame.Show() if options['file']: frame.LoadFile(options['file']) app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.giface import StandaloneGrassInterface from core.globalvar import CheckWxVersion from gmodeler.frame import ModelFrame app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() frame = ModelFrame(parent=None, giface=StandaloneGrassInterface()) if options['file']: frame.LoadModelFile(options['file']) frame.Show() app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from psmap.frame import PsMapFrame app = wx.App() frame = PsMapFrame( parent=None, title=_("Cartographic Composer - GRASS GIS"), ) frame.Show() if options["file"]: frame.LoadFile(options["file"]) app.MainLoop()
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.giface import StandaloneGrassInterface from gmodeler.frame import ModelFrame app = wx.App() frame = ModelFrame( parent=None, giface=StandaloneGrassInterface(), title=_("Graphical Modeler - GRASS GIS"), ) if options['file']: frame.LoadModelFile(options['file']) frame.Show() app.MainLoop()
def main(): grass.set_raise_on_error(False) options, flags = grass.parser() # import wx only after running parser # to avoid issues with complex imports when only interface is needed import wx from grass.script.setup import set_gui_path set_gui_path() from core.render import Map from mapdisp.frame import MapFrame from mapdisp.main import DMonGrassInterface from core.settings import UserSettings from vdigit.main import haveVDigit, errorMsg from grass.exceptions import CalledModuleError # define classes which needs imports as local # for longer definitions, a separate file would be a better option class VDigitMapFrame(MapFrame): def __init__(self, vectorMap): MapFrame.__init__(self, parent=None, Map=Map(), giface=DMonGrassInterface(None), title=_("Vector Digitizer - GRASS GIS"), size=(850, 600)) # this giface issue not solved yet, we must set mapframe aferwards self._giface._mapframe = self # load vector map mapLayer = self.GetMap().AddLayer( ltype='vector', name=vectorMap, command=['d.vect', 'map=%s' % vectorMap], active=True, hidden=False, opacity=1.0, render=True) # switch toolbar self.AddToolbar('vdigit', fixed=True) # start editing self.toolbars['vdigit'].StartEditing(mapLayer) if not haveVDigit: grass.fatal(_("Vector digitizer not available. %s") % errorMsg) if not grass.find_file(name=options['map'], element='vector', mapset=grass.gisenv()['MAPSET'])['fullname']: if not flags['c']: grass.fatal( _("Vector map <%s> not found in current mapset. " "New vector map can be created by providing '-c' flag.") % options['map']) else: grass.verbose(_("New vector map <%s> created") % options['map']) try: grass.run_command('v.edit', map=options['map'], tool='create', quiet=True) except CalledModuleError: grass.fatal( _("Unable to create new vector map <%s>") % options['map']) # allow immediate rendering driver = UserSettings.Get(group='display', key='driver', subkey='type') if driver == 'png': os.environ['GRASS_RENDER_IMMEDIATE'] = 'png' else: os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo' app = wx.App() frame = VDigitMapFrame(options['map']) frame.Show() app.MainLoop()
def main(): gs.set_raise_on_error(False) options, flags = gs.parser() # import wx only after running parser # to avoid issues with complex imports when only interface is needed import wx from grass.script.setup import set_gui_path set_gui_path() from core.render import Map from mapdisp.frame import MapFrame from mapdisp.main import DMonGrassInterface from core.settings import UserSettings from grass.exceptions import CalledModuleError # define classes which needs imports as local # for longer definitions, a separate file would be a better option class RDigitMapFrame(MapFrame): def __init__( self, new_map=None, base_map=None, edit_map=None, map_type=None, ): MapFrame.__init__( self, parent=None, Map=Map(), giface=DMonGrassInterface(None), title=_("GRASS GIS Raster Digitizer"), size=(850, 600), ) # this giface issue not solved yet, we must set mapframe aferwards self._giface._mapframe = self self._giface.mapCreated.connect(self.OnMapCreated) self._mapObj = self.GetMap() # load raster map self._addLayer(name=new_map if new_map else edit_map) # switch toolbar self.AddToolbar('rdigit', fixed=True) rdigit = self.toolbars['rdigit'] if new_map: rdigit._mapSelectionCombo.Unbind(wx.EVT_COMBOBOX) self.rdigit.SelectNewMap( standalone=True, mapName=new_map, bgMap=base_map, mapType=map_type, ) rdigit._mapSelectionCombo.Bind( wx.EVT_COMBOBOX, rdigit.OnMapSelection, ) else: rdigit._mapSelectionCombo.SetSelection(n=1) rdigit.OnMapSelection() def _addLayer(self, name, ltype='raster'): """Add layer into map :param str name: map name :param str ltype: layer type """ mapLayer = self._mapObj.AddLayer( ltype=ltype, name=name, command=['d.rast', "map={}".format(name)], active=True, hidden=False, opacity=1.0, render=True, ) def OnMapCreated(self, name, ltype): """Add new created raster layer into map :param str name: map name :param str ltype: layer type """ self._mapObj.Clean() self._addLayer(name=name, ltype=ltype) self.GetMapWindow().UpdateMap() kwargs = { 'new_map': options['create'], 'base_map': options['base'], 'edit_map': options['edit'], 'map_type': options['type'], } mapset = gs.gisenv()['MAPSET'] if kwargs['edit_map']: edit_map = gs.find_file( name=kwargs['edit_map'], element='raster', mapset=mapset, )['fullname'] if not edit_map: gs.fatal( _( "Raster map <{}> not found in current mapset.".format( options['edit'], ), ), ) else: kwargs['edit_map'] = edit_map else: if kwargs['base_map']: base_map = gs.find_file( name=kwargs['base_map'], element='raster', mapset=mapset, )['fullname'] if not base_map: gs.fatal( _( "Base raster map <{}> not found in " "current mapset.".format(options['base'], ), ), ) kwargs['base_map'] = base_map # allow immediate rendering driver = UserSettings.Get( group='display', key='driver', subkey='type', ) if driver == 'png': os.environ['GRASS_RENDER_IMMEDIATE'] = 'png' else: os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo' app = wx.App() frame = RDigitMapFrame(**kwargs) frame.Show() app.MainLoop()
@author Vaclav Petras <wenzeslaus gmail.com> (refactoring) @author Anna Kratochvilova <kratochanna gmail.com> (refactoring) """ import textwrap import wx from wx import stc from grass.pydispatch.signal import Signal # needed just for testing if __name__ == "__main__": from grass.script.setup import set_gui_path set_gui_path() from core.gcmd import GError from core.gconsole import ( GConsole, EVT_CMD_OUTPUT, EVT_CMD_PROGRESS, EVT_CMD_RUN, EVT_CMD_DONE, Notification, ) from core.globalvar import CheckWxVersion, wxPythonPhoenix from gui_core.prompt import GPromptSTC from gui_core.wrap import Button, ClearButton, ToggleButton, StaticText, StaticBox from core.settings import UserSettings
def main(): options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.giface import StandaloneGrassInterface try: from tplot.frame import TplotFrame except ImportError as e: gscript.fatal(e.message) rasters = None if options['strds']: rasters = options['strds'].strip().split(',') coords = None if options['coordinates']: coords = options['coordinates'].strip().split(',') cats = None if options['cats']: cats = options['cats'] output = options['output'] vectors = None attr = None if options['stvds']: vectors = options['stvds'].strip().split(',') if not options['attr']: gscript.fatal(_("With stvds you have to set 'attr' option")) else: attr = options['attr'] if coords and cats: gscript.fatal(_("With stvds it is not possible to use 'coordinates' " "and 'cats' options together")) elif not coords and not cats: gscript.warning(_("With stvds you have to use 'coordinates' or " "'cats' option")) title = None if options['title']: title = options['title'] xlabel = None if options['xlabel']: xlabel = options['xlabel'] ylabel = None if options['ylabel']: ylabel = options['ylabel'] csvfile = None if options['csv']: csvfile = options['csv'] app = wx.App() frame = TplotFrame( parent=None, giface=StandaloneGrassInterface(), title=_("Temporal Plot Tool - GRASS GIS"), ) if flags['l']: frame.linRegRaster.SetValue(state=True) frame.linRegVector.SetValue(state=True) frame.SetDatasets(rasters, vectors, coords, cats, attr, title, xlabel, ylabel, csvfile, flags['h'], gscript .overwrite) if output: frame.OnRedraw() if options['size']: sizes = options['size'].strip().split(',') sizes = [int(s) for s in sizes] frame.canvas.SetSize(sizes) frame.canvas.figure.savefig(output) else: frame.Show() app.MainLoop()
def main(): gscript.set_raise_on_error(False) options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from core.globalvar import CheckWxVersion from core.giface import StandaloneGrassInterface from core.utils import _ from iclass.frame import IClassMapFrame group_name = subgroup_name = map_name = trainingmap_name = None if options['group']: if not options['subgroup']: gscript.fatal(_("Name of subgroup required")) group_name = gscript.find_file(name=options['group'], element='group')['name'] if not group_name: gscript.fatal(_("Group <%s> not found") % options['group']) subgroups = gscript.read_command('i.group', group=group_name, flags='sg').splitlines() if options['subgroup'] not in subgroups: gscript.fatal(_("Subgroup <%s> not found") % options['subgroup']) subgroup_name = options['subgroup'] if options['map']: map_name = gscript.find_file(name=options['map'], element='cell')['fullname'] if not map_name: gscript.fatal(_("Raster map <%s> not found") % options['map']) if options['trainingmap']: trainingmap_name = gscript.find_file(name=options['trainingmap'], element='vector')['fullname'] if not trainingmap_name: gscript.fatal( _("Vector map <%s> not found") % options['trainingmap']) # define display driver driver = UserSettings.Get(group='display', key='driver', subkey='type') if driver == 'png': os.environ['GRASS_RENDER_IMMEDIATE'] = 'png' else: os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo' # launch application app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() # show main frame giface = StandaloneGrassInterface() frame = IClassMapFrame(parent=None, giface=giface) if not flags['m']: frame.CenterOnScreen() if group_name: frame.SetGroup(group_name, subgroup_name) if map_name: giface.WriteLog(_("Loading raster map <%s>...") % map_name) frame.trainingMapManager.AddLayer(map_name) if trainingmap_name: giface.WriteLog(_("Loading training map <%s>...") % trainingmap_name) frame.ImportAreas(trainingmap_name) frame.Show() if flags['m']: frame.Maximize() app.MainLoop()
def main(): gscript.set_raise_on_error(False) options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from core.giface import StandaloneGrassInterface from iclass.frame import IClassMapFrame group_name = subgroup_name = map_name = trainingmap_name = None if options['group']: if not options['subgroup']: gscript.fatal(_("Name of subgroup required")) group_name = gscript.find_file(name=options['group'], element='group')['name'] if not group_name: gscript.fatal(_("Group <%s> not found") % options['group']) subgroups = gscript.read_command('i.group', group=group_name, flags='sg').splitlines() if options['subgroup'] not in subgroups: gscript.fatal(_("Subgroup <%s> not found") % options['subgroup']) subgroup_name = options['subgroup'] if options['map']: map_name = gscript.find_file(name=options['map'], element='cell')['fullname'] if not map_name: gscript.fatal(_("Raster map <%s> not found") % options['map']) if options['trainingmap']: trainingmap_name = gscript.find_file(name=options['trainingmap'], element='vector')['fullname'] if not trainingmap_name: gscript.fatal( _("Vector map <%s> not found") % options['trainingmap']) # define display driver driver = UserSettings.Get(group='display', key='driver', subkey='type') if driver == 'png': os.environ['GRASS_RENDER_IMMEDIATE'] = 'png' else: os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo' # launch application app = wx.App() # show main frame giface = StandaloneGrassInterface() frame = IClassMapFrame(parent=None, giface=giface) if not flags['m']: frame.CenterOnScreen() if group_name: frame.SetGroup(group_name, subgroup_name) if map_name: giface.WriteLog(_("Loading raster map <%s>...") % map_name) frame.trainingMapManager.AddLayer(map_name) if trainingmap_name: giface.WriteLog(_("Loading training map <%s>...") % trainingmap_name) frame.ImportAreas(trainingmap_name) frame.Show() if flags['m']: frame.Maximize() app.MainLoop()
def main(): gscript.set_raise_on_error(False) options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from iclass.frame import IClassMapFrame group_name = subgroup_name = map_name = trainingmap_name = None if options["group"]: if not options["subgroup"]: gscript.fatal(_("Name of subgroup required")) group_name = gscript.find_file(name=options["group"], element="group")["name"] if not group_name: gscript.fatal(_("Group <%s> not found") % options["group"]) subgroups = gscript.read_command("i.group", group=group_name, flags="sg").splitlines() if options["subgroup"] not in subgroups: gscript.fatal(_("Subgroup <%s> not found") % options["subgroup"]) subgroup_name = options["subgroup"] if options["map"]: map_name = gscript.find_file(name=options["map"], element="cell")["fullname"] if not map_name: gscript.fatal(_("Raster map <%s> not found") % options["map"]) if options["trainingmap"]: trainingmap_name = gscript.find_file(name=options["trainingmap"], element="vector")["fullname"] if not trainingmap_name: gscript.fatal( _("Vector map <%s> not found") % options["trainingmap"]) # define display driver driver = UserSettings.Get(group="display", key="driver", subkey="type") if driver == "png": os.environ["GRASS_RENDER_IMMEDIATE"] = "png" else: os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo" # launch application app = wx.App() # show main frame frame = IClassMapFrame( parent=None, giface=None, title=_("Supervised Classification Tool - GRASS GIS"), ) if not flags["m"]: frame.CenterOnScreen() if group_name: frame.SetGroup(group_name, subgroup_name) if map_name: frame.giface.WriteLog(_("Loading raster map <%s>...") % map_name) frame.trainingMapManager.AddLayer(map_name) if trainingmap_name: frame.giface.WriteLog( _("Loading training map <%s>...") % trainingmap_name) frame.ImportAreas(trainingmap_name) frame.Show() if flags["m"]: frame.Maximize() app.MainLoop()
def main(): options, flags = gscript.parser() # import wx only after running parser # to avoid issues when only interface is needed import grass.temporal as tgis import wx from grass.script.setup import set_gui_path set_gui_path() from core.giface import StandaloneGrassInterface from core.layerlist import LayerList from animation.frame import AnimationFrame, MAX_COUNT from animation.data import AnimLayer rast = options['raster'] vect = options['vector'] strds = options['strds'] stvds = options['stvds'] numInputs = 0 if rast: numInputs += 1 if vect: numInputs += 1 if strds: numInputs += 1 if stvds: numInputs += 1 if numInputs > 1: gscript.fatal(_("%s=, %s=, %s= and %s= are mutually exclusive.") % ("raster", "vector", "strds", "stvds")) if numInputs > 0: # We need to initialize the temporal framework in case # a space time dataset was set on the command line so that # the AnimLayer() class works correctly try: tgis.init() except FatalError as e: print(e) layerList = LayerList() if rast: layer = AnimLayer() layer.mapType = 'raster' layer.name = rast layer.cmd = ['d.rast', 'map={name}'.format(name=rast.split(',')[0])] layerList.AddLayer(layer) if vect: layer = AnimLayer() layer.mapType = 'vector' layer.name = vect layer.cmd = ['d.vect', 'map={name}'.format(name=vect.split(',')[0])] layerList.AddLayer(layer) if strds: layer = AnimLayer() layer.mapType = 'strds' layer.name = strds layer.cmd = ['d.rast', 'map='] layerList.AddLayer(layer) if stvds: layer = AnimLayer() layer.mapType = 'stvds' layer.name = stvds layer.cmd = ['d.vect', 'map='] layerList.AddLayer(layer) app = wx.App() frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface()) frame.CentreOnScreen() frame.Show() if len(layerList) >= 1: # CallAfter added since it was crashing with wxPython 3 gtk wx.CallAfter(frame.SetAnimations, [layerList] + [None] * (MAX_COUNT - 1)) app.MainLoop()
def main(): options, flags = gscript.parser() # import wx only after running parser # to avoid issues when only interface is needed import grass.temporal as tgis import wx from grass.script.setup import set_gui_path set_gui_path() from core.globalvar import CheckWxVersion from core.utils import _ from core.giface import StandaloneGrassInterface from core.layerlist import LayerList from animation.frame import AnimationFrame, MAX_COUNT from animation.data import AnimLayer rast = options['raster'] vect = options['vector'] strds = options['strds'] stvds = options['stvds'] numInputs = 0 if rast: numInputs += 1 if vect: numInputs += 1 if strds: numInputs += 1 if stvds: numInputs += 1 if numInputs > 1: gscript.fatal(_("%s=, %s=, %s= and %s= are mutually exclusive.") % ("raster", "vector", "strds", "stvds")) if numInputs > 0: # We need to initialize the temporal framework in case # a space time dataset was set on the command line so that # the AnimLayer() class works correctly tgis.init() layerList = LayerList() if rast: layer = AnimLayer() layer.mapType = 'raster' layer.name = rast layer.cmd = ['d.rast', 'map={name}'.format(name=rast.split(',')[0])] layerList.AddLayer(layer) if vect: layer = AnimLayer() layer.mapType = 'vector' layer.name = vect layer.cmd = ['d.vect', 'map={name}'.format(name=vect.split(',')[0])] layerList.AddLayer(layer) if strds: layer = AnimLayer() layer.mapType = 'strds' layer.name = strds layer.cmd = ['d.rast', 'map='] layerList.AddLayer(layer) if stvds: layer = AnimLayer() layer.mapType = 'stvds' layer.name = stvds layer.cmd = ['d.vect', 'map='] layerList.AddLayer(layer) app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface()) frame.CentreOnScreen() frame.Show() if len(layerList) >= 1: # CallAfter added since it was crashing with wxPython 3 gtk wx.CallAfter(frame.SetAnimations, [layerList] + [None] * (MAX_COUNT - 1)) app.MainLoop()
def main(): gs.set_raise_on_error(False) options, flags = gs.parser() # import wx only after running parser # to avoid issues with complex imports when only interface is needed import wx from grass.script.setup import set_gui_path set_gui_path() from core.render import Map from mapdisp.frame import MapFrame from mapdisp.main import DMonGrassInterface from core.settings import UserSettings # define classes which needs imports as local # for longer definitions, a separate file would be a better option class RDigitMapFrame(MapFrame): def __init__( self, new_map=None, base_map=None, edit_map=None, map_type=None, ): MapFrame.__init__( self, parent=None, Map=Map(), giface=DMonGrassInterface(None), title=_("Raster Digitizer - GRASS GIS"), size=(850, 600), ) # this giface issue not solved yet, we must set mapframe afterwards self._giface._mapframe = self self._giface.mapCreated.connect(self.OnMapCreated) self._mapObj = self.GetMap() # load raster map self._addLayer(name=new_map if new_map else edit_map) # switch toolbar self.AddToolbar("rdigit", fixed=True) rdigit = self.toolbars["rdigit"] if new_map: rdigit._mapSelectionCombo.Unbind(wx.EVT_COMBOBOX) self.rdigit.SelectNewMap( standalone=True, mapName=new_map, bgMap=base_map, mapType=map_type, ) rdigit._mapSelectionCombo.Bind( wx.EVT_COMBOBOX, rdigit.OnMapSelection, ) else: rdigit._mapSelectionCombo.SetSelection(n=1) rdigit.OnMapSelection() # use Close instead of QuitRDigit for standalone tool self.rdigit.quitDigitizer.disconnect(self.QuitRDigit) self.rdigit.quitDigitizer.connect(lambda: self.Close()) def _addLayer(self, name, ltype="raster"): """Add layer into map :param str name: map name :param str ltype: layer type """ mapLayer = self._mapObj.AddLayer( ltype=ltype, name=name, command=["d.rast", "map={}".format(name)], active=True, hidden=False, opacity=1.0, render=True, ) def OnMapCreated(self, name, ltype): """Add new created raster layer into map :param str name: map name :param str ltype: layer type """ self._mapObj.Clean() self._addLayer(name=name, ltype=ltype) self.GetMapWindow().UpdateMap() kwargs = { "new_map": options["create"], "base_map": options["base"], "edit_map": options["edit"], "map_type": options["type"], } mapset = gs.gisenv()["MAPSET"] if kwargs["edit_map"]: edit_map = gs.find_file( name=kwargs["edit_map"], element="raster", mapset=mapset, )["fullname"] if not edit_map: gs.fatal( _( "Raster map <{}> not found in current mapset.".format( options["edit"], ), ), ) else: kwargs["edit_map"] = edit_map else: if kwargs["base_map"]: base_map = gs.find_file( name=kwargs["base_map"], element="raster", mapset=mapset, )["fullname"] if not base_map: gs.fatal( _( "Base raster map <{}> not found in " "current mapset.".format(options["base"], ), ), ) kwargs["base_map"] = base_map # allow immediate rendering driver = UserSettings.Get( group="display", key="driver", subkey="type", ) if driver == "png": os.environ["GRASS_RENDER_IMMEDIATE"] = "png" else: os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo" app = wx.App() frame = RDigitMapFrame(**kwargs) frame.Show() app.MainLoop()
def main(): """Sets the GRASS display driver""" options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from core.giface import StandaloneGrassInterface from photo2image.ip2i_manager import GCPWizard driver = UserSettings.Get(group="display", key="driver", subkey="type") if driver == "png": os.environ["GRASS_RENDER_IMMEDIATE"] = "png" else: os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo" if options["group"]: group = options["group"] else: gscript.fatal(_("Please provide a group name to process")) if options["raster"]: raster = options["raster"] else: gscript.fatal(_("Please provide a raster map name to process")) if options["camera"]: camera = options["camera"] else: gscript.fatal( _("Please provide a camera name (generated by i.ortho.camera)")) if options["order"]: order = options["order"] else: gscript.fatal( _("Please provive an order value (1 if 4 Fiducials, 2 if 8 Fiducials)" )) if options["extension"]: extension = options["extension"] else: gscript.fatal( _("Please provive an output files extension (used by i.rectify)")) app = wx.App() wizard = GCPWizard( parent=None, giface=StandaloneGrassInterface(), group=group, raster=raster, raster1=raster, camera=camera, order=order, extension=extension, ) app.MainLoop()
""" Created on Wed Nov 20 14:44:32 2013 @author: anna """ import os import wx import wx.lib.newevent import wx.lib.filebrowsebutton as filebrowse from shutil import copyfile from grass.script.utils import set_path, get_lib_path set_path(modulename='g.gui.tangible') from grass.script.setup import set_gui_path set_gui_path() from gui_core.gselect import Select from core.settings import UserSettings import grass.script as gscript from grass.pydispatch.signal import Signal from tangible_utils import run_analyses updateGUIEvt, EVT_UPDATE_GUI = wx.lib.newevent.NewCommandEvent() class AnalysesPanel(wx.Panel): def __init__(self, parent, giface, settings):
def main(): grass.set_raise_on_error(False) options, flags = grass.parser() # import wx only after running parser # to avoid issues with complex imports when only interface is needed import wx from grass.script.setup import set_gui_path set_gui_path() from core.globalvar import CheckWxVersion from core.utils import _ from core.render import Map from mapdisp.frame import MapFrame from mapdisp.main import DMonGrassInterface from core.settings import UserSettings from vdigit.main import haveVDigit, errorMsg from grass.exceptions import CalledModuleError # define classes which needs imports as local # for longer definitions, a separate file would be a better option class VDigitMapFrame(MapFrame): def __init__(self, vectorMap): MapFrame.__init__( self, parent=None, Map=Map(), giface=DMonGrassInterface(None), title=_("GRASS GIS Vector Digitizer"), size=(850, 600)) # this giface issue not solved yet, we must set mapframe aferwards self._giface._mapframe = self # load vector map mapLayer = self.GetMap().AddLayer( ltype='vector', name=vectorMap, command=['d.vect', 'map=%s' % vectorMap], active=True, hidden=False, opacity=1.0, render=True) # switch toolbar self.AddToolbar('vdigit', fixed=True) # start editing self.toolbars['vdigit'].StartEditing(mapLayer) if not haveVDigit: grass.fatal(_("Vector digitizer not available. %s") % errorMsg) if not grass.find_file(name=options['map'], element='vector', mapset=grass.gisenv()['MAPSET'])['fullname']: if not flags['c']: grass.fatal(_("Vector map <%s> not found in current mapset. " "New vector map can be created by providing '-c' flag.") % options['map']) else: grass.verbose(_("New vector map <%s> created") % options['map']) try: grass.run_command('v.edit', map=options['map'], tool='create', quiet=True) except CalledModuleError: grass.fatal(_("Unable to create new vector map <%s>") % options['map']) # allow immediate rendering driver = UserSettings.Get(group='display', key='driver', subkey='type') if driver == 'png': os.environ['GRASS_RENDER_IMMEDIATE'] = 'png' else: os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo' app = wx.App() if not CheckWxVersion([2, 9]): wx.InitAllImageHandlers() frame = VDigitMapFrame(options['map']) frame.Show() app.MainLoop()
def main(): grass.set_raise_on_error(False) options, flags = grass.parser() # import wx only after running parser # to avoid issues with complex imports when only interface is needed import wx from grass.script.setup import set_gui_path set_gui_path() from core.render import Map from core.globalvar import ICONDIR from mapdisp.frame import MapPanel from gui_core.mapdisp import FrameMixin from mapdisp.main import DMonGrassInterface from core.settings import UserSettings from vdigit.main import haveVDigit, errorMsg from grass.exceptions import CalledModuleError # define classes which needs imports as local # for longer definitions, a separate file would be a better option class VDigitMapDisplay(FrameMixin, MapPanel): """Map display for wrapping map panel with v.digit mathods and frame methods""" def __init__(self, parent, vectorMap): MapPanel.__init__(self, parent=parent, Map=Map(), giface=DMonGrassInterface(None)) # set system icon parent.SetIcon( wx.Icon(os.path.join(ICONDIR, "grass_map.ico"), wx.BITMAP_TYPE_ICO)) # bindings parent.Bind(wx.EVT_CLOSE, self.OnCloseWindow) # extend shortcuts and create frame accelerator table self.shortcuts_table.append( (self.OnFullScreen, wx.ACCEL_NORMAL, wx.WXK_F11)) self._initShortcuts() # this giface issue not solved yet, we must set mapframe aferwards self._giface._mapframe = self # load vector map mapLayer = self.GetMap().AddLayer( ltype="vector", name=vectorMap, command=["d.vect", "map=%s" % vectorMap], active=True, hidden=False, opacity=1.0, render=True, ) # switch toolbar self.AddToolbar("vdigit", fixed=True) # start editing self.toolbars["vdigit"].StartEditing(mapLayer) # use Close instead of QuitVDigit for standalone tool self.toolbars["vdigit"].quitDigitizer.disconnect(self.QuitVDigit) self.toolbars["vdigit"].quitDigitizer.connect(lambda: self.Close()) # add Map Display panel to Map Display frame sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self, proportion=1, flag=wx.EXPAND) parent.SetSizer(sizer) parent.Layout() if not haveVDigit: grass.fatal(_("Vector digitizer not available. %s") % errorMsg) if not grass.find_file(name=options["map"], element="vector", mapset=grass.gisenv()["MAPSET"])["fullname"]: if not flags["c"]: grass.fatal( _("Vector map <%s> not found in current mapset. " "New vector map can be created by providing '-c' flag.") % options["map"]) else: grass.verbose(_("New vector map <%s> created") % options["map"]) try: grass.run_command("v.edit", map=options["map"], tool="create", quiet=True) except CalledModuleError: grass.fatal( _("Unable to create new vector map <%s>") % options["map"]) # allow immediate rendering driver = UserSettings.Get(group="display", key="driver", subkey="type") if driver == "png": os.environ["GRASS_RENDER_IMMEDIATE"] = "png" else: os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo" app = wx.App() frame = wx.Frame( None, id=wx.ID_ANY, size=(850, 600), style=wx.DEFAULT_FRAME_STYLE, title=_("Vector Digitizer - GRASS GIS"), ) frame = VDigitMapDisplay(parent=frame, vectorMap=options["map"]) frame.Show() app.MainLoop()
def main(): """ Sets the GRASS display driver """ options, flags = gscript.parser() import wx from grass.script.setup import set_gui_path set_gui_path() from core.settings import UserSettings from core.giface import StandaloneGrassInterface from image2target.ii2t_manager import GCPWizard driver = UserSettings.Get(group="display", key="driver", subkey="type") if driver == "png": os.environ["GRASS_RENDER_IMMEDIATE"] = "png" else: os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo" # if options['source_location']: # src_loc = options['source_location'] # else: # gscript.fatal(_("No georeferenced source location provided")) # if options['source_mapset']: # src_mpt = options['source_mapset'] # else: # gscript.fatal(_("No georeferenced source mapset provided")) # if options['source_group']: # src_grp = options['source_group'] # else: # gscript.fatal(_("Please provide a source group name to process")) # if options['source_image']: # src_ras = options['source_image'] # else: # gscript.fatal(_("Please provide a source image map name to process")) # if options['target_image']: # tgt_ras = options['target_image'] # else: # gscript.fatal(_("No georeferenced target map provided")) # if options['camera']: # camera = options['camera'] # else: # gscript.fatal(_("Please provide a camera name (generated by i.ortho.camera)")) # if options['order']: # order = options['order'] # else: # gscript.fatal(_("Please provive an order value")) # if options['extension']: # extension = options['extension'] # else: # gscript.fatal(_("Please provide an output file extension")) app = wx.App() # wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface(), # srcloc=src_loc,srcmpt=src_mpt,srcgrp=src_grp,srcras=src_ras, # tgtras=tgt_ras,camera=camera, order=order, extension=extension) wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface()) app.MainLoop()