def processAlgorithm(self, progress): '''Here is where the processing itself takes place''' mask = self.getParameterValue(self.MASK) output = self.getOutputValue(self.OUTPUT_RASTER) cs = self.getParameterValue(self.CS) ext = self.getParameterValue(self.EXTENT) if mask != None: src = gdal.Open(str(mask), gdalconst.GA_ReadOnly) mask = src.GetRasterBand(1).ReadAsArray() try: ext = string.split(ext,",") # split except AttributeError: # Extent was empty, raise error raise GeoAlgorithmExecutionException("Please set an extent for the generated raster") # Processing # Create output layer xmin = float(ext[0]) xmax = float(ext[1]) ymin = float(ext[2]) ymax = float(ext[3]) gt = (xmin,cs,0,ymax,0,-cs) nodata = -9999 cols = int( round( (xmax-xmin)/cs ) ) rows = int( round( (ymax-ymin)/cs ) ) # Do the calc result = nlmpy.randomUniform01(rows, cols, mask=mask) # Create output raster func.createRaster(output,cols,rows,result,nodata,gt)
def processAlgorithm(self, progress): '''Here is where the processing itself takes place''' ncla = self.getParameterValue(self.CLASSES) inputSource = self.getParameterValue(self.SOURCE) output = self.getOutputValue(self.OUTPUT_RASTER) cs = self.getParameterValue(self.CS) mask = self.getParameterValue(self.MASK) if mask != None: src = gdal.Open(str(mask), gdalconst.GA_ReadOnly) mask = src.GetRasterBand(1).ReadAsArray() # Source src = gdal.Open(str(inputSource), gdalconst.GA_ReadOnly) src_geotrans = src.GetGeoTransform() cols = src.RasterXSize rows = src.RasterYSize nodata = src.GetRasterBand(1).GetNoDataValue() # keep the nodata value array = src.GetRasterBand(1).ReadAsArray() # Classes cl = range(1,ncla+1) # Do the calc result = nlmpy.classifyArray(array,cl,mask) # Create output raster func.createRaster(output,cols,rows,result,nodata,src_geotrans)
def processAlgorithm(self, progress): '''Here is where the processing itself takes place''' inputSource = self.getParameterValue(self.SOURCE) output = self.getOutputValue(self.OUTPUT_RASTER) cs = self.getParameterValue(self.CS) # Source src = gdal.Open(str(inputSource), gdalconst.GA_ReadOnly) src_geotrans = src.GetGeoTransform() cols = src.RasterXSize rows = src.RasterYSize nodata = src.GetRasterBand(1).GetNoDataValue() # keep the nodata value array = src.GetRasterBand(1).ReadAsArray() # Do the calc result = nlmpy.linearRescale01(array) # Create output raster func.createRaster(output,cols,rows,result,nodata,src_geotrans)