Exemple #1
0
def main():
    group_name = subgroup_name = map_name = trainingmap_name = None

    if options['group']:
        if not options['subgroup']:
            grass.fatal(_("Name of subgroup required"))
        group_name = grass.find_file(name=options['group'],
                                     element='group')['name']
        if not group_name:
            grass.fatal(_("Group <%s> not found") % options['group'])
        if options['subgroup'] not in grass.read_command(
                'i.group', group=group_name, flags='sg').splitlines():
            grass.fatal(_("Subgroup <%s> not found") % options['subgroup'])
        subgroup_name = options['subgroup']

    if options['map']:
        map_name = grass.find_file(name=options['map'],
                                   element='cell')['fullname']
        if not map_name:
            grass.fatal(_("Raster map <%s> not found") % options['map'])

    if options['trainingmap']:
        trainingmap_name = grass.find_file(name=options['trainingmap'],
                                           element='vector')['fullname']
        if not trainingmap_name:
            grass.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()
Exemple #2
0
def main():
    options, flags = gcore.parser()
    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
    giface = StandaloneGrassInterface()
    frame = ExampleMapFrame(parent=None, giface=giface)
    if options['input']:
        giface.WriteLog(_("Loading raster map <{raster}>...").format(raster=map_name))
        frame.SetLayer(map_name)

    frame.Show()
    app.MainLoop()
Exemple #3
0
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()
Exemple #4
0
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,
        title=_("Supervised Classification Tool - GRASS GIS"),
    )
    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()