Exemplo n.º 1
0
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()
Exemplo n.º 2
0
def main():
    try:
        from tplot.frame import TplotFrame
    except ImportError as e:
        grass.fatal(e.message)

    datasets = options['inputs'].strip().split(',')
    datasets = [data for data in datasets if data]
    coords = options['coordinates'].strip().split(',')
    output = options['output']
    dpi = options['dpi']
    dpi = int(dpi) if dpi else None
    if dpi and not output:
        grass.warning(_("No output filename set, so DPI option will not used"))

    app = wx.App()
    frame = TplotFrame(None)
    frame.SetDatasets(datasets, coords, output, dpi)
    if output:
        return

    frame.Show()
    app.MainLoop()
Exemplo n.º 3
0
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()