def main(): if options['type'] == "point to centroid": type_cnv = "point,centroid" elif options['type'] == "point to kernel": type_cnv = "point,kernel" elif options['type'] == "centroid to point": type_cnv = "centroid,point" elif options['type'] == "centroid to kernel": type_cnv = "centroid,kernel" elif options['type'] == "kernel to point": type_cnv = "kernel,point" elif options['type'] == "kernel to centroid": type_cnv = "kernel,centroid" elif options['type'] == "line to boundary": type_cnv = "line,boundary" elif options['type'] == "line to face": type_cnv = "line,face" elif options['type'] == "boundary to line": type_cnv = "boundary,line" elif options['type'] == "boundary to face": type_cnv = "boundary,face" elif options['type'] == "face to line": type_cnv = "face,line" elif options['type'] == "face to boundary": type_cnv = "face,boundary" options.pop('type') grass.exec_command("v.type", type = type_cnv, **options) return 0
def main(): if options['type'] == "point to centroid": type_cnv = "point,centroid" elif options['type'] == "point to kernel": type_cnv = "point,kernel" elif options['type'] == "centroid to point": type_cnv = "centroid,point" elif options['type'] == "centroid to kernel": type_cnv = "centroid,kernel" elif options['type'] == "kernel to point": type_cnv = "kernel,point" elif options['type'] == "kernel to centroid": type_cnv = "kernel,centroid" elif options['type'] == "line to boundary": type_cnv = "line,boundary" elif options['type'] == "line to face": type_cnv = "line,face" elif options['type'] == "boundary to line": type_cnv = "boundary,line" elif options['type'] == "boundary to face": type_cnv = "boundary,face" elif options['type'] == "face to line": type_cnv = "face,line" elif options['type'] == "face to boundary": type_cnv = "face,boundary" options.pop('type') grass.exec_command("v.type", type=type_cnv, **options) return 0
def main(): grass.exec_command( "v.distance", _from = options['map'], to = options['qmap'], column = options['column'], to_column = options['qcolumn'], upload = "to_attr", dmax = options['dmax'], from_layer = options['layer'], to_layer = options['qlayer'])
def main(): handler = options["handler"] if options["tempfile"]: img_tmp = options["tempfile"] # TODO: add option for GRASS_RENDER_FILE_COMPRESSION=0,1-9 else: img_tmp = grass.tempfile() os.remove(img_tmp) img_tmp += ".bmp" if flags["b"]: print('GRASS_RENDER_FILE="%s"' % img_tmp) if "GRASS_RENDER_WIDTH" not in os.environ: print("GRASS_RENDER_WIDTH=%s" % options["width"]) if "GRASS_RENDER_HEIGHT" not in os.environ: print("GRASS_RENDER_HEIGHT=%s" % options["height"]) if flags["c"]: print("GRASS_RENDER_IMMEDIATE=cairo") else: print("GRASS_RENDER_IMMEDIATE=PNG") print("GRASS_RENDER_FILE_MAPPED=TRUE") print("GRASS_RENDER_FILE_READ=TRUE") print( "export GRASS_RENDER_FILE GRASS_RENDER_WIDTH GRASS_RENDER_HEIGHT GRASS_RENDER_IMMEDIATE GRASS_RENDER_FILE_MAPPED GRASS_RENDER_FILE_READ;" ) print("d.erase bgcolor=%s;" % options["color"]) if handler == "none": grass.message("Image file is '%s'" % img_tmp) elif handler == "qiv": print('qiv -e -T "%s" &' % img_tmp) # add --center ? else: print('%s image="%s" percent=%s &' % (handler, img_tmp, options["percent"])) sys.exit(0) if flags["d"]: print("rem DOS export not yet implemented") sys.exit(0) ## rest of this won't work, as parent can't inherit from the child.. ## (unless we do some ugly g.gisenv) ## ... any ideas? end by running grass.call(['bash'])? if not grass.find_program(handler, "--help"): grass.fatal(_("'%s' not found.") % handler) os.environ["GRASS_RENDER_FILE"] = img_tmp if "GRASS_RENDER_WIDTH" not in os.environ: os.environ["GRASS_RENDER_WIDTH"] = options["width"] if "GRASS_RENDER_HEIGHT" not in os.environ: os.environ["GRASS_RENDER_HEIGHT"] = options["height"] if flags["c"]: os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo" os.environ["GRASS_RENDER_FILE_MAPPED"] = "TRUE" os.environ["GRASS_RENDER_FILE_READ"] = "TRUE" # ? os.environ['GRASS_PNG_AUTO_WRITE'] = 'FALSE' grass.run_command("d.erase", bgcolor=options["color"]) if handler == "qiv": ret = grass.call(["qiv", "-e", "-T", img_tmp]) else: ret = grass.exec_command(handler, image=img_tmp, percent=options["percent"]) os.remove(img_tmp) sys.exit(ret)
def main(): grass.exec_command("g.gui", flags='nu', gui=options['gui']) return 0
def main(): handler = options['handler'] if options['tempfile']: img_tmp = options['tempfile'] #TODO: add option for GRASS_RENDER_FILE_COMPRESSION=0,1-9 else: img_tmp = grass.tempfile() os.remove(img_tmp) img_tmp += ".bmp" if flags['b']: print('GRASS_RENDER_FILE="%s"' % img_tmp) if not os.environ.has_key("GRASS_RENDER_WIDTH"): print('GRASS_RENDER_WIDTH=%s' % options['width']) if not os.environ.has_key("GRASS_RENDER_HEIGHT"): print('GRASS_RENDER_HEIGHT=%s' % options['height']) if flags['c']: print('GRASS_RENDER_IMMEDIATE=cairo') else: print('GRASS_RENDER_IMMEDIATE=PNG') print('GRASS_RENDER_FILE_MAPPED=TRUE') print('GRASS_RENDER_FILE_READ=TRUE') print( 'export GRASS_RENDER_FILE GRASS_RENDER_WIDTH GRASS_RENDER_HEIGHT GRASS_RENDER_IMMEDIATE GRASS_RENDER_FILE_MAPPED GRASS_RENDER_FILE_READ;' ) print('d.erase bgcolor=%s;' % options['color']) if handler == "none": grass.message("Image file is '%s'" % img_tmp) elif handler == "qiv": print('qiv -e -T "%s" &' % img_tmp) # add --center ? else: print('%s image="%s" percent=%s &' % (handler, img_tmp, options['percent'])) sys.exit(0) if flags['d']: print('rem DOS export not yet implemented') sys.exit(0) ## rest of this won't work, as parent can't inherit from the child.. ## (unless we do some ugly g.gisenv) ## ... any ideas? end by running grass.call(['bash'])? if not grass.find_program(handler, '--help'): grass.fatal(_("'%s' not found.") % handler) os.environ['GRASS_RENDER_FILE'] = img_tmp if not os.environ.has_key("GRASS_RENDER_WIDTH"): os.environ['GRASS_RENDER_WIDTH'] = options['width'] if not os.environ.has_key("GRASS_RENDER_HEIGHT"): os.environ['GRASS_RENDER_HEIGHT'] = options['height'] if flags['c']: os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo' os.environ['GRASS_RENDER_FILE_MAPPED'] = 'TRUE' os.environ['GRASS_RENDER_FILE_READ'] = 'TRUE' #? os.environ['GRASS_PNG_AUTO_WRITE'] = 'FALSE' grass.run_command('d.erase', bgcolor=options['color']) if handler == "qiv": ret = grass.call(['qiv', '-e', '-T', img_tmp]) else: ret = grass.exec_command(handler, image=img_tmp, percent=options['percent']) os.remove(img_tmp) sys.exit(ret)
def main(): grass.exec_command("g.gui", flags = 'nu', gui = options['gui']) return 0