"""
OGR Buffer process
Author: Jachym Cepicky (jachym@les-ejk.cz)
"""
import os
import sys
os.environ["GISBASE"] = "/usr/lib/grass64"
gbase = os.getenv("GISBASE")
pypath = os.path.join(gbase,'etc','gui','wxpython','gui_modules')
sys.path.append(pypath)
os.environ["PYTHONPATH"] = "/usr/local/grass-7.0.svn/etc/python"
pypath = os.path.join(gbase,'etc','python')
sys.path.append(pypath)
cpath = os.getenv("PATH")
path = cpath + ":" + gbase + "/bin" + ":" + gbase + "/scripts"
os.environ["PATH"]=path
lpath = os.getenv("LD_LIBRARY_PATH")
if lpath!=None:
libpath = lpath + ":" + gbase + "/lib"
else:
libpath = gbase + "/lib"
os.environ["LD_LIBRARY_PATH"]=libpath
#os.environ["GIS_LOCK"]="$$"
os.environ["GISRC"]="/opt/grass-lite/grassrc"
os.system("export LOCATION_NAME=spearfish60")
from grass.script import core as grass
from pywps.Process import WPSProcess
from osgeo import ogr
class Process(WPSProcess):
def __init__(self):
##
# Process initialization
WPSProcess.__init__(self,
identifier = "ogrbuffer",
title="Geotiff to PNG conversion",
version = "1.0",
grassLocation = True,
storeSupported = True,
statusSupported = True)
self.outputImage=self.addComplexOutput(identifier="output",title="output image",formats=[{'mimeType':'image/png'}])
def execute(self):
#r.external links an external raster file into a GRASS map layer
self.cmd("g.gisenv set=LOCATION_NAME=spearfish60")
self.cmd(['r.external', 'input=/home/rashad/rr.tif', 'output=inputImage','-o' ])
self.cmd(['g.region',"rast=inputImage"])
self.cmd(["r.out.png","input=inputImage","output=./tmp.png"])
self.outputImage.setValue("./tmp.png")