Skip to content
Permalink
Browse files

(WIP) Grass algorithms can be opened and inputs are treated

  • Loading branch information
Médéric Ribreux
Médéric Ribreux committed Sep 4, 2017
1 parent a676db2 commit be78153427aad77b78fcf6c3e59b613e579442ab

Large diffs are not rendered by default.

@@ -89,6 +89,7 @@ def installedVersion(run=False):
if Grass7Utils.grassPath() is None:
return None

# Does this works on MS-Windows?
for command in ["grass73", "grass72", "grass71", "grass70", "grass"]:
with subprocess.Popen(
["{} -v".format(command)],
@@ -114,13 +115,17 @@ def installedVersion(run=False):

@staticmethod
def grassPath():
# Grab folder from Processing configuration
if not isWindows() and not isMac():
return ''

folder = ProcessingConfig.getSetting(Grass7Utils.GRASS_FOLDER) or ''
if not os.path.exists(folder):
folder = None

# If no folder is declared, search for it
if folder is None:
# Under MSWindows, we use OSGEO4W
if isWindows():
if "OSGEO4W_ROOT" in os.environ:
testfolder = os.path.join(str(os.environ['OSGEO4W_ROOT']), "apps")
@@ -132,10 +137,19 @@ def grassPath():
if subfolder.startswith('grass-7'):
folder = os.path.join(testfolder, subfolder)
break
else:
# On Mac, we use well-known paths
if isMac():
folder = os.path.join(str(QgsApplication.prefixPath()), 'grass7')
if not os.path.isdir(folder):
folder = '/Applications/GRASS-7.0.app/Contents/MacOS'
# GNU/Linux OS: autodetect path by using shutil.which
# TO test: does this works under MSWindows ?
else:
for command in ["grass73", "grass72", "grass71", "grass70", "grass"]:
testFolder = shutil.which(command)
if testFolder:
folder = testFolder
break

return folder or ''

@@ -387,28 +401,28 @@ def checkGrass7IsInstalled(ignorePreviousState=False):
if not ignorePreviousState:
if Grass7Utils.isGrass7Installed:
return
try:
from processing import run
result = run(
'grass7:v.voronoi',
points(),
False,
False,
None,
-1,
0.0001,
0,
None,
)
if not os.path.exists(result['output']):
return Grass7Utils.tr(
'It seems that GRASS GIS 7 is not correctly installed and '
'configured in your system.\nPlease install it before '
'running GRASS GIS 7 algorithms.')
except:
return Grass7Utils.tr(
'Error while checking GRASS GIS 7 installation. GRASS GIS 7 '
'might not be correctly configured.\n')
#try:
# from processing import run
# result = run(
# 'grass7:v.voronoi',
# points(),
# False,
# False,
# None,
# -1,
# 0.0001,
# 0,
# None,
# )
# if not os.path.exists(result['output']):
# return Grass7Utils.tr(
# 'It seems that GRASS GIS 7 is not correctly installed and '
# 'configured in your system.\nPlease install it before '
# 'running GRASS GIS 7 algorithms.')
#except:
# return Grass7Utils.tr(
# 'Error while checking GRASS GIS 7 installation. GRASS GIS 7 '
# 'might not be correctly configured.\n')

Grass7Utils.isGrass7Installed = True

@@ -452,7 +466,7 @@ def grassHelpPath():
if helpPath is not None:
return helpPath
elif Grass7Utils.command:
return 'http://grass.osgeo.org/{}/manuals/'.format(Grass7Utils.command)
return 'https://grass.osgeo.org/{}/manuals/'.format(Grass7Utils.command)
else:
# grass not available!
return 'http://grass.osgeo.org/72/manuals/'
return 'https://grass.osgeo.org/72/manuals/'
@@ -4,12 +4,12 @@ Raster (r.*)
QgsProcessingParameterFile|input|LAS input file|False|False
QgsProcessingParameterEnum|method|Statistic to use for raster values|n;min;max;range;sum;mean;stddev;variance;coeff_var;median;percentile;skewness;trimmean|False|5
QgsProcessingParameterEnum|type|Storage type for resultant raster map|CELL;FCELL;DCELL|False|1
QgsProcessingParameterString|zrange|Filter range for z data (min, max)|None|False|True
QgsProcessingParameterRange|zrange|Filter range for z data (min, max)|QgsProcessingParameterNumber.Double|None|True
QgsProcessingParameterNumber|zscale|Scale to apply to z data|QgsProcessingParameterNumber.Double|1.0|True|0.0|None
QgsProcessingParameterNumber|percent|Percent of map to keep in memory|1|QgsProcessingParameterNumber.Double|True|False|100|100
QgsProcessingParameterString|pth|pth percentile of the values (between 1 and 100)|None|False|True
QgsProcessingParameterString|trim|Discard <trim> percent of the smallest and <trim> percent of the largest observations (0-50)|None|False|True
QgsProcessingParameterString|resolution|Output raster resolution|None|False|True
QgsProcessingParameterNumber|percent|Percent of map to keep in memory|QgsProcessingParameterNumber.Integer|100|True|1|100
QgsProcessingParameterNumber|pth|pth percentile of the values (between 1 and 100)|QgsProcessingParameterNumber.Integer|None|True|1|100
QgsProcessingParameterNumber|trim|Discard <trim> percent of the smallest and <trim> percent of the largest observations (0-50)|QgsProcessingParameterNumber.Double|None|True|0.0|50.0
QgsProcessingParameterNumber|resolution|Output raster resolution|QgsProcessingParameterNumber.Double|None|True|None|None
QgsProcessingParameterString|return_filter|Only import points of selected return type Options: first, last, mid|None|False|True
QgsProcessingParameterString|class_filter|Only import points of selected class(es) (comma separated integers)|None|False|True
*QgsProcessingParameterBoolean|-i|Import intensity values rather than z values|False
@@ -1,10 +1,10 @@
r.random.surface
Generates random surface(s) with spatial dependence.
Raster (r.*)
QgsProcessingParameterNumber|distance|Maximum distance of spatial correlation|0.0|QgsProcessingParameterNumber.Double|True|False|0.0|None
QgsProcessingParameterNumber|exponent|Distance decay exponent|0.0|QgsProcessingParameterNumber.Double|True|False|1.0|None
QgsProcessingParameterNumber|flat|Distance filter remains flat before beginning exponent|0.0|QgsProcessingParameterNumber.Double|True|False|0.0|None
QgsProcessingParameterNumber|distance|Maximum distance of spatial correlation|QgsProcessingParameterNumber.Double|0.0|True|0.0|None
QgsProcessingParameterNumber|exponent|Distance decay exponent|QgsProcessingParameterNumber.Double|1.0|True|0.0|None
QgsProcessingParameterNumber|flat|Distance filter remains flat before beginning exponent|QgsProcessingParameterNumber.Double|0.0|True|0.0|None
QgsProcessingParameterString|seed|Integer random seed (SEED_MIN >= value >= SEED_MAX), default [random]|None|False|True
QgsProcessingParameterNumber|high|Maximum cell value of distribution|0|QgsProcessingParameterNumber.Double|True|False|255|None
QgsProcessingParameterNumber|high|Maximum cell value of distribution|QgsProcessingParameterNumber.Integer|255|True|0|None
QgsProcessingParameterBoolean|-u|Uniformly distributed cell values|False|True
QgsProcessingParameterRasterDestination|output|Random_Surface
@@ -4,10 +4,10 @@ Raster (r.*)
QgsProcessingParameterRasterLayer|input|Input raster layer|None|False
QgsProcessingParameterRasterLayer|mask|Name of raster map to use for masking. Only cells that are not NULL and not zero are interpolated|None|True
QgsProcessingParameterEnum|method|Sampling interpolation method|bilinear;bicubic|1|False|False
QgsProcessingParameterNumber|ew_step|Length (float) of each spline step in the east-west direction|0.0|QgsProcessingParameterNumber.Double|True|False|1.0|None
QgsProcessingParameterNumber|ns_step|Length (float) of each spline step in the north-south direction|0.0|QgsProcessingParameterNumber.Double|True|False|1.0|None
QgsProcessingParameterNumber|lambda|Tykhonov regularization parameter (affects smoothing)|0.0|QgsProcessingParameterNumber.Double|True|False|0.01|None
QgsProcessingParameterNumber|memory|Maximum memory to be used (in MB). Cache size for raster rows|10|QgsProcessingParameterNumber.Double|True|False|300|None
QgsProcessingParameterNumber|ew_step|Length (float) of each spline step in the east-west direction|QgsProcessingParameterNumber.Double|1.0|True|0.0|None
QgsProcessingParameterNumber|ns_step|Length (float) of each spline step in the north-south direction|QgsProcessingParameterNumber.Double|1.0|True|0.0|None
QgsProcessingParameterNumber|lambda|Tykhonov regularization parameter (affects smoothing)|QgsProcessingParameterNumber.Double|0.01|True|0.0|None
QgsProcessingParameterNumber|memory|Maximum memory to be used (in MB). Cache size for raster rows|QgsProcessingParameterNumber.Integer|300|True|10|None
*QgsProcessingParameterBoolean|-n|Only interpolate null cells in input raster map|False|True
*QgsProcessingParameterBoolean|-c|Find the best Tykhonov regularizing parameter using a "leave-one-out" cross validation method|False|True
QgsProcessingParameterRasterDestination|output|Resampled BSpline
@@ -3,10 +3,10 @@ Makes each output cell value an accumulation function of the values assigned to
Raster (r.*)
QgsProcessingParameterMultipleLayers|input|Input raster layer(s)|3.0|None|False
QgsProcessingParameterEnum|method|This method will be applied to compute the accumulative values from the input maps|gdd;bedd;huglin;mean|False|0
QgsProcessingParameterNumber|scale|Scale factor for input|0.0|QgsProcessingParameterNumber.Double|True|False|1.0|None
QgsProcessingParameterNumber|shift|Shift factor for input|0.0|QgsProcessingParameterNumber.Double|True|False|0.0|None
QgsProcessingParameterString|range|Ignore values outside this range (min,max)|-10000000000,10000000000|False|True
QgsProcessingParameterString|limits|Lower and upper accumulation limits (lower,upper)|10,30|False|True
QgsProcessingParameterNumber|scale|Scale factor for input|QgsProcessingParameterNumber.Double|1.0|True|0.0|None
QgsProcessingParameterNumber|shift|Shift factor for input|QgsProcessingParameterNumber.Double|0.0|True|0.0|None
QgsProcessingParameterRange|range|Ignore values outside this range (min,max)|QgsProcessingParameterNumber.Double|None|True
QgsProcessingParameterRange|limits|Lower and upper accumulation limits (lower,upper)|QgsProcessingParameterNumber.Integer|10,30|True
QgsProcessingParameterBoolean|-n|Propagate NULLs|False
*QgsProcessingParameterBoolean|-f|Create a FCELL map (floating point single precision) as output|False
QgsProcessingParameterRasterDestination|output|Accumulated
@@ -10,9 +10,9 @@ QgsProcessingParameterRasterLayer|wind_speed|Raster map containing midflame wind
QgsProcessingParameterRasterLayer|fuel_moisture|Raster map containing fine fuel moisture of the cell receiving a spotting firebrand (%, required with -s)|None|True
QgsProcessingParameterRasterLayer|backdrop|Name of raster map as a display backdrop|None|True
QgsProcessingParameterEnum|least_size|Basic sampling window size needed to meet certain accuracy (3)|3;5;7;9;11;13;15|False|0
QgsProcessingParameterNumber|comp_dens|Sampling density for additional computing (range: 0.0 - 1.0 (0.5))|0.0|QgsProcessingParameterNumber.Double|True|False|0.5|1.0
QgsProcessingParameterNumber|init_time|Initial time for current simulation (0) (min)|0|QgsProcessingParameterNumber.Double|True|False|0|None
QgsProcessingParameterNumber|lag|Simulating time duration LAG (fill the region) (min)|0|QgsProcessingParameterNumber.Double|True|False|0|None
QgsProcessingParameterNumber|comp_dens|Sampling density for additional computing (range: 0.0 - 1.0 (0.5))|QgsProcessingParameterNumber.Double|0.5|True|0.0|1.0
QgsProcessingParameterNumber|init_time|Initial time for current simulation (0) (min)|QgsProcessingParameterNumber.Integer|0|True|0|None
QgsProcessingParameterNumber|lag|Simulating time duration LAG (fill the region) (min)|QgsProcessingParameterNumber.Integer|0|True|0|None
*QgsProcessingParameterBoolean|-s|Consider spotting effect (for wildfires)|False
*QgsProcessingParameterBoolean|-i|Use start raster map values in output spread time raster map|False
QgsProcessingParameterRasterDestination|output|Spread Time
@@ -3,9 +3,9 @@ r.stats.quantile.out - Compute category quantiles using two passes and output st
Raster (r.*)
QgsProcessingParameterRasterLayer|base|Name of base raster map|None|False
QgsProcessingParameterRasterLayer|cover|Name of cover raster map|None|False
QgsProcessingParameterString|quantiles|Number of quantiles|None|False|True
QgsProcessingParameterNumber|quantiles|Number of quantiles|QgsProcessingParameterNumber.Integer|None|True|0|None
QgsProcessingParameterString|percentiles|List of percentiles|None|False|True
QgsProcessingParameterNumber|bins|Number of bins to use|0|QgsProcessingParameterNumber.Double|True|False|1000|None
QgsProcessingParameterNumber|bins|Number of bins to use|QgsProcessingParameterNumber.Integer|1000|True|0|None
*QgsProcessingParameterBoolean|-r|Create reclass map with statistics as category labels|False
Hardcoded|-p
OutputFile|output|Statistics File
@@ -3,9 +3,9 @@ r.stats.quantile.rast - Compute category quantiles using two passes and output r
Raster (r.*)
QgsProcessingParameterRasterLayer|base|Name of base raster map|None|False
QgsProcessingParameterRasterLayer|cover|Name of cover raster map|None|False
QgsProcessingParameterNumber|quantiles|Number of quantiles|2|QgsProcessingParameterNumber.Double|True|False|2|None
QgsProcessingParameterNumber|quantiles|Number of quantiles|QgsProcessingParameterNumber.Integer|None|True|0|None
QgsProcessingParameterString|percentiles|List of percentiles|None|False|True
QgsProcessingParameterNumber|bins|Number of bins to use|0|QgsProcessingParameterNumber.Double|True|False|1000|None
QgsProcessingParameterNumber|bins|Number of bins to use|QgsProcessingParameterNumber.Integer|1000|True|0|None
*QgsProcessingParameterBoolean|-r|Create reclass map with statistics as category labels|False
OutputDirectory|output_dir|Output Directory

@@ -1,12 +1,12 @@
r.sunhours
Calculates solar elevation, solar azimuth, and sun hours.
Raster (r.*)
QgsProcessingParameterNumber|year|Year|1950|QgsProcessingParameterNumber.Double|False|False|2016|2050
QgsProcessingParameterNumber|month|Month|1|QgsProcessingParameterNumber.Double|True|False|1|12
QgsProcessingParameterNumber|day|Day|1|QgsProcessingParameterNumber.Double|False|False|1|31
QgsProcessingParameterNumber|hour|Hour|0|QgsProcessingParameterNumber.Double|True|False|12|24
QgsProcessingParameterNumber|minute|Minutes|0|QgsProcessingParameterNumber.Double|True|False|0|60
QgsProcessingParameterNumber|second|Seconds|0|QgsProcessingParameterNumber.Double|True|False|0|60
QgsProcessingParameterNumber|year|Year|QgsProcessingParameterNumber.Integer|2017|False|1950|None
QgsProcessingParameterNumber|month|Month|QgsProcessingParameterNumber.Integer|1|True|1|12
QgsProcessingParameterNumber|day|Day|QgsProcessingParameterNumber.Integer|1|False|1|31
QgsProcessingParameterNumber|hour|Hour|0|QgsProcessingParameterNumber.Integer|12|True|1|24
QgsProcessingParameterNumber|minute|Minutes|QgsProcessingParameterNumber.Integer|0|True|0|60
QgsProcessingParameterNumber|second|Seconds|QgsProcessingParameterNumber.Integer|0|True|0|60
QgsProcessingParameterString|percentile|Percentile to calculate (comma separated list if multiple) (requires extended statistics flag)|None|False|True
QgsProcessingParameterString|separator|Field separator. Special characters: pipe, comma, space, tab, newline|None|False|True
*QgsProcessingParameterBoolean|-t|Time is local sidereal time, not Greenwich standard time|False
@@ -1,6 +1,6 @@
r.surf.fractal
Creates a fractal surface of a given fractal dimension.
Raster (r.*)
QgsProcessingParameterNumber|dimension|Fractal dimension of surface (2 < D < 3)|2.0|QgsProcessingParameterNumber.Double|True|False|2.05|3.0
QgsProcessingParameterNumber|number|Number of intermediate images to produce|0|QgsProcessingParameterNumber.Double|True|False|0|None
QgsProcessingParameterNumber|dimension|Fractal dimension of surface (2 < D < 3)|QgsProcessingParameterNumber.Double|2.05|True|2.0|3.0
QgsProcessingParameterNumber|number|Number of intermediate images to produce|QgsProcessingParameterNumber.Integer|0|True|0|None
QgsProcessingParameterRasterDestination|output|Fractal Surface
@@ -3,8 +3,8 @@ Generate images with textural features from a raster map.
Raster (r.*)
QgsProcessingParameterRasterLayer|input|Name of input raster map|None|False
QgsProcessingParameterString|method|Textural measurement method(s) in the following list: asm, contrast, corr, var, idm, sa, se, sv, entr, dv, de, moc1, moc2|None|False|True
QgsProcessingParameterNumber|size|The size of moving window (odd and >= 3)|3.0|QgsProcessingParameterNumber.Double|True|False|3.0|None
QgsProcessingParameterNumber|distance|The distance between two samples (>= 1)|1.0|QgsProcessingParameterNumber.Double|True|False|1.0|None
QgsProcessingParameterNumber|size|The size of moving window (odd and >= 3)|QgsProcessingParameterNumber.Double|3.0|True|3.0|None
QgsProcessingParameterNumber|distance|The distance between two samples (>= 1)|QgsProcessingParameterNumber.Double|1.0|True|1.0|None
*QgsProcessingParameterBoolean|-s|Separate output for each angle (0, 45, 90, 135)|False
*QgsProcessingParameterBoolean|-a|Calculate all textural measurements|False
OutputDirectory|output|Texture files directory
@@ -5,9 +5,9 @@ QgsProcessingParameterString|sourceproj|Source projection|None|True|False
QgsProcessingParameterString|sourcescale|Conversion factor from units to meters in source projection|1|False|True
QgsProcessingParameterString|destproj|Destination projection|None|True|False
QgsProcessingParameterString|destscale|Conversion factor from units to meters in destination projection|1|False|True
QgsProcessingParameterNumber|maxcols|Maximum number of columns for a tile in the source projection|1|QgsProcessingParameterNumber.Double|True|False|1024|None
QgsProcessingParameterNumber|maxrows|Maximum number of rows for a tile in the source projection|1|QgsProcessingParameterNumber.Double|True|False|1024|None
QgsProcessingParameterNumber|overlap|Number of cells tiles should overlap in each direction|0|QgsProcessingParameterNumber.Double|True|False|0|None
QgsProcessingParameterNumber|maxcols|Maximum number of columns for a tile in the source projection|QgsProcessingParameterNumber.Integer|1024|True|1|None
QgsProcessingParameterNumber|maxrows|Maximum number of rows for a tile in the source projection|QgsProcessingParameterNumber.Integer|1024|True|1|None
QgsProcessingParameterNumber|overlap|Number of cells tiles should overlap in each direction|QgsProcessingParameterNumber.Integer|0|True|0|None
QgsProcessingParameterString|separator|Output field separator|None|False|True
*QgsProcessingParameterBoolean|-g|Produces shell script output|False
*QgsProcessingParameterBoolean|-w|Produces web map server query string output|False
@@ -13,19 +13,6 @@ i.segment.txt
i.smap.txt
i.topo.corr.ill.txt
i.topo.corr.txt
r.blend.combine.txt
r.blend.rgb.txt
r.fillnulls.txt
r.in.lidar.txt
r.random.surface.txt
r.resamp.bspline.txt
r.series.accumulate.txt
r.spread.txt
r.stats.quantile.out.txt
r.stats.quantile.rast.txt
r.sunhours.txt
r.surf.fractal.txt
r.texture.txt
r.tileset.txt
r.topmodel.topidxstats.txt
r.viewshed.txt

0 comments on commit be78153

Please sign in to comment.
You can’t perform that action at this time.