Advertisement
Guest User

Untitled

a guest
Jul 11th, 2011
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. """
  2. OGR Buffer process
  3.  
  4. Author: Jachym Cepicky (jachym@les-ejk.cz)
  5. """
  6.  
  7. import os
  8. import sys
  9. os.environ["GISBASE"] = "/usr/lib/grass64"
  10. gbase = os.getenv("GISBASE")
  11.  
  12. pypath = os.path.join(gbase,'etc','gui','wxpython','gui_modules')
  13.  
  14. sys.path.append(pypath)
  15. os.environ["PYTHONPATH"] = "/usr/local/grass-7.0.svn/etc/python"
  16. pypath = os.path.join(gbase,'etc','python')
  17.  
  18. sys.path.append(pypath)
  19.  
  20. cpath = os.getenv("PATH")
  21. path = cpath + ":" + gbase + "/bin" + ":" + gbase + "/scripts"
  22. os.environ["PATH"]=path
  23.  
  24. lpath = os.getenv("LD_LIBRARY_PATH")
  25. if lpath!=None:
  26. libpath = lpath + ":" + gbase + "/lib"
  27. else:
  28. libpath = gbase + "/lib"
  29. os.environ["LD_LIBRARY_PATH"]=libpath
  30. #os.environ["GIS_LOCK"]="$$"
  31. os.environ["GISRC"]="/opt/grass-lite/grassrc"
  32.  
  33. os.system("export LOCATION_NAME=spearfish60")
  34.  
  35. from grass.script import core as grass
  36. from pywps.Process import WPSProcess
  37. from osgeo import ogr
  38.  
  39.  
  40.  
  41. class Process(WPSProcess):
  42.  
  43. def __init__(self):
  44.  
  45. ##
  46. # Process initialization
  47. WPSProcess.__init__(self,
  48. identifier = "ogrbuffer",
  49. title="Geotiff to PNG conversion",
  50. version = "1.0",
  51. grassLocation = True,
  52. storeSupported = True,
  53. statusSupported = True)
  54.  
  55.  
  56. self.outputImage=self.addComplexOutput(identifier="output",title="output image",formats=[{'mimeType':'image/png'}])
  57.  
  58.  
  59. def execute(self):
  60. #r.external links an external raster file into a GRASS map layer
  61. self.cmd("g.gisenv set=LOCATION_NAME=spearfish60")
  62. self.cmd(['r.external', 'input=/home/rashad/rr.tif', 'output=inputImage','-o' ])
  63. self.cmd(['g.region',"rast=inputImage"])
  64. self.cmd(["r.out.png","input=inputImage","output=./tmp.png"])
  65. self.outputImage.setValue("./tmp.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement