Merge pull request #2865 from medspx/processing_raster_bunch

[Processing] Add the last GRASS7 r.* algorithms
This commit is contained in:
volaya 2016-03-23 10:39:58 +01:00
commit 2e6fcf57d6
134 changed files with 3646 additions and 19 deletions

View File

@ -0,0 +1,9 @@
r.blend
r.blend.combine - Blends color components of two raster maps by a given ratio and export into a unique raster.
Raster (r.*)
ParameterRaster|first|Name of first raster map for blending|False
ParameterRaster|second|Name of second raster map for blending|False
ParameterNumber|percent|Percentage weight of first map for color blending|0.0|100.0|50.0|True
Hardcoded|-c
OutputRaster|output|Blended

View File

@ -0,0 +1,10 @@
r.blend
r.blend.rgb - Blends color components of two raster maps by a given ratio and exports into three rasters.
Raster (r.*)
ParameterRaster|first|Name of first raster map for blending|False
ParameterRaster|second|Name of second raster map for blending|False
ParameterNumber|percent|Percentage weight of first map for color blending|0.0|100.0|50.0|True
OutputRaster|output_red|Blended Red
OutputRaster|output_green|Blended Green
OutputRaster|output_blue|Blended Blue

View File

@ -0,0 +1,8 @@
r.buffer.lowmem
Creates a raster map layer showing buffer zones surrounding cells that contain non-NULL category values (low-memory alternative).
Raster (r.*)
ParameterRaster|input|Input raster layer|False
ParameterString|distances|Distance zone(s) (e.g. 100,200,300)|None|False|False
ParameterSelection|units|Units of distance|meters;kilometers;feet;miles;nautmiles|False
ParameterBoolean|-z|Ignore zero (0) data cells instead of NULL cells|False
OutputRaster|output|Buffer

View File

@ -2,7 +2,7 @@ r.buffer
Creates a raster map layer showing buffer zones surrounding cells that contain non-NULL category values.
Raster (r.*)
ParameterRaster|input|Input raster layer|False
ParameterString|distances|Distance zone(s) (e.g. 100,200,300)|
ParameterSelection|units|Units of distance|meters;kilometers;feet;miles;nautmiles
ParameterString|distances|Distance zone(s) (e.g. 100,200,300)|None|False|False
ParameterSelection|units|Units of distance|meters;kilometers;feet;miles;nautmiles|False
ParameterBoolean|-z|Ignore zero (0) data cells instead of NULL cells|False
OutputRaster|output|Buffer

View File

@ -0,0 +1,8 @@
r.category
r.category.out - Exports category values and labels associated with user-specified raster map layers.
Raster (r.*)
ParameterRaster|map|Name of raster map|False
ParameterString|cats|Category values (for Integer rasters). Example: 1,3,7-9,13|None|False|True
ParameterString|values|Comma separated value list (for float rasters). Example: 1.4,3.8,13|None|False|True
ParameterString|separator|Field separator (Special characters: pipe, comma, space, tab, newline)|tab|False|True
OutputFile|output|Category

View File

@ -0,0 +1,11 @@
r.category
Manages category values and labels associated with user-specified raster map layers.
Raster (r.*)
ParameterRaster|map|Name of raster map|False
ParameterString|separator|Field separator (Special characters: pipe, comma, space, tab, newline)|tab|False|True
ParameterFile|rules|File containing category label rules|False|True
ParameterString|txtrules|Inline category label rules|None|True|True
ParameterRaster|raster|Raster map from which to copy category table|True
*ParameterString|format|Default label or format string for dynamic labeling. Used when no explicit label exists for the category|None|False|True
*ParameterString|coefficients|Dynamic label coefficients. Two pairs of category multiplier and offsets, for $1 and $2|None|False|True
OutputRaster|output|Category

View File

@ -0,0 +1,6 @@
r.colors.out
Exports the color table associated with a raster map.
Raster (r.*)
ParameterRaster|map|Name of raster map|False
*ParameterBoolean|-p|Output values as percentages|False|True
OutputFile|rules|Color Table

View File

@ -0,0 +1,7 @@
r.colors.stddev
Sets color rules based on stddev from a raster map's mean value.
Raster (r.*)
ParameterRaster|map|Name of raster map|False
*ParameterBoolean|-b|Color using standard deviation bands|False
*ParameterBoolean|-z|Force center at zero|False
OutputRaster|output|Stddev Colors

View File

@ -0,0 +1,16 @@
r.colors
Creates/modifies the color table associated with a raster map.
Raster (r.*)
ParameterMultipleInput|map|Name of raster maps(s)|3|False
ParameterSelection|color|Name of color table|not selected;aspect;aspectcolr;bcyr;bgyr;blues;byg;byr;celsius;corine;curvature;differences;elevation;etopo2;evi;fahrenheit;gdd;greens;grey;grey.eq;grey.log;grey1.0;grey255;gyr;haxby;kelvin;ndvi;ndwi;oranges;population;population_dens;precipitation;precipitation_daily;precipitation_monthly;rainbow;ramp;random;reds;rstcurv;ryb;ryg;sepia;slope;srtm;srtm_plus;terrain;wave|0|False|True
ParameterString|rules_txt|Color rules|None|True|True
ParameterFile|rules|Color rules file|False|True
ParameterRaster|raster|Raster map from which to copy color table|True
ParameterBoolean|-r|Remove existing color table|False
ParameterBoolean|-w|Only write new color table if it does not already exist|False
ParameterBoolean|-n|Invert colors|False
ParameterBoolean|-g|Logarithmic scaling|False
ParameterBoolean|-a|Logarithmic-absolute scaling|False
ParameterBoolean|-e|Histogram equalization|False
OutputDirectory|output_dir|Output Directory

View File

@ -0,0 +1,10 @@
r.distance
Locates the closest points between objects in two raster maps.
Raster (r.*)
ParameterMultipleInput|map|Name of two input raster for computing inter-class distances|3|False
ParameterString|separator|Field separator (Special characters: pipe, comma, space, tab, newline)|:|False|True
ParameterSelection|sort|Sort output by distance|asc;desc
*ParameterBoolean|-l|Include category labels in the output|False|True
*ParameterBoolean|-o|Report zero distance if rasters are overlapping|False|True
*ParameterBoolean|-n|Report null objects as *|False|True
OutputFile|output|Distance

View File

@ -2,9 +2,12 @@ r.drain
Traces a flow through an elevation model on a raster map.
Raster (r.*)
ParameterRaster|input|Elevation|False
ParameterString|start_coordinates|Map coordinates of starting point(s) (E,N)|(0,0)
ParameterMultipleInput|start_points|Vector layer(s) containing starting point(s)|0|True
ParameterRaster|direction|Name of input movement direction map associated with the cost surface|True
ParameterString|start_coordinates|Map coordinates of starting point(s) (E,N)|0.0,0.0|False|True
ParameterVector|start_points|Vector layer containing starting point(s)|0|True
ParameterBoolean|-c|Copy input cell values on output|False
ParameterBoolean|-a|Accumulate input values along the path|False
ParameterBoolean|-n|Count cell numbers along the path|False
ParameterBoolean|-d|The input raster map is a cost surface (direction surface must also be specified)|False
OutputRaster|output|Least cost path
OutputVector|drain|Drain

View File

@ -0,0 +1,6 @@
r.latlong
Creates a latitude/longitude raster map.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterBoolean|-l|Outputs a Longitude map instead of a Latitude map|False|True
OutputRaster|output|LatLong

View File

@ -0,0 +1,8 @@
r.li.cwed
r.li.cwed.ascii - Calculates contrast weighted edge density index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
ParameterFile|path|Name of file that contains the weight to calculate the index|False
OutputFile|output|CWED

View File

@ -0,0 +1,8 @@
r.li.cwed
Calculates contrast weighted edge density index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
ParameterFile|path|Name of file that contains the weight to calculate the index|False
OutputRaster|output|CWED

View File

@ -0,0 +1,7 @@
r.li.dominance
r.li.dominance.ascii - Calculates dominance's diversity index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Dominance

View File

@ -0,0 +1,7 @@
r.li.dominance
Calculates dominance's diversity index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Dominance

View File

@ -0,0 +1,9 @@
r.li.edgedensity
r.li.edgedensity.ascii - Calculates edge density index on a raster map, using a 4 neighbour algorithm
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
ParameterString|patch_type|The value of the patch type|None|False|True
ParameterBoolean|-b|Exclude border edges|False
OutputFile|output|Edge Density

View File

@ -0,0 +1,9 @@
r.li.edgedensity
Calculates edge density index on a raster map, using a 4 neighbour algorithm
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
ParameterString|patch_type|The value of the patch type|None|False|True
ParameterBoolean|-b|Exclude border edges|False
OutputRaster|output|Edge Density

View File

@ -0,0 +1,7 @@
r.li.mpa
r.li.mpa.ascii - Calculates mean pixel attribute index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Mean Pixel Attribute

View File

@ -0,0 +1,7 @@
r.li.mpa
Calculates mean pixel attribute index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Mean Pixel Attribute

View File

@ -0,0 +1,7 @@
r.li.mps
r.li.mps.ascii - Calculates mean patch size index on a raster map, using a 4 neighbour algorithm
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Mean Patch Size

View File

@ -0,0 +1,7 @@
r.li.mps
Calculates mean patch size index on a raster map, using a 4 neighbour algorithm
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Mean Patch Size

View File

@ -0,0 +1,7 @@
r.li.padcv
r.li.padcv.ascii - Calculates coefficient of variation of patch area on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|PADCV

View File

@ -0,0 +1,7 @@
r.li.padcv
Calculates coefficient of variation of patch area on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|PADCV

View File

@ -0,0 +1,7 @@
r.li.padrange
r.li.padrange.ascii - Calculates range of patch area size on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Pad Range

View File

@ -0,0 +1,7 @@
r.li.padrange
Calculates range of patch area size on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Pad Range

View File

@ -0,0 +1,7 @@
r.li.padsd
r.li.padsd.ascii - Calculates standard deviation of patch area a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Patch Area SD

View File

@ -0,0 +1,7 @@
r.li.padsd
Calculates standard deviation of patch area a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Patch Area SD

View File

@ -0,0 +1,7 @@
r.li.patchdensity
r.li.patchdensity.ascii - Calculates patch density index on a raster map, using a 4 neighbour algorithm
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Patch Density

View File

@ -0,0 +1,7 @@
r.li.patchdensity
Calculates patch density index on a raster map, using a 4 neighbour algorithm
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Patch Density

View File

@ -0,0 +1,7 @@
r.li.patchnum
r.li.patchnum.ascii - Calculates patch number index on a raster map, using a 4 neighbour algorithm.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Patch Number

View File

@ -0,0 +1,7 @@
r.li.patchnum
Calculates patch number index on a raster map, using a 4 neighbour algorithm.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Patch Number

View File

@ -0,0 +1,7 @@
r.li.pielou
r.li.pielou.ascii - Calculates Pielou's diversity index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Pielou

View File

@ -0,0 +1,7 @@
r.li.pielou
Calculates Pielou's diversity index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Pielou

View File

@ -0,0 +1,8 @@
r.li.renyi
r.li.renyi.ascii - Calculates Renyi's diversity index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
ParameterString|alpha|Alpha value is the order of the generalized entropy|None|False|True
OutputFile|output|Renyi

View File

@ -0,0 +1,8 @@
r.li.renyi
Calculates Renyi's diversity index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
ParameterString|alpha|Alpha value is the order of the generalized entropy|None|False|True
OutputRaster|output|Renyi

View File

@ -0,0 +1,7 @@
r.li.richness
r.li.richness.ascii - Calculates richness index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Richness

View File

@ -0,0 +1,7 @@
r.li.richness
Calculates richness index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Richness

View File

@ -0,0 +1,7 @@
r.li.shannon
r.li.shannon.ascii - Calculates Shannon's diversity index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Shannon

View File

@ -0,0 +1,7 @@
r.li.shannon
Calculates Shannon's diversity index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Shannon

View File

@ -0,0 +1,7 @@
r.li.shape
r.li.shape.ascii - Calculates shape index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Shape

View File

@ -0,0 +1,7 @@
r.li.shape
Calculates shape index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Shape

View File

@ -0,0 +1,7 @@
r.li.simpson
r.li.simpson.ascii - Calculates Simpson's diversity index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputFile|output|Simpson

View File

@ -0,0 +1,7 @@
r.li.simpson
Calculates Simpson's diversity index on a raster map
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|config_txt|Landscape structure configuration|None|True|True
ParameterFile|config|Landscape structure configuration file|False|True
OutputRaster|output|Simpson

View File

@ -0,0 +1,9 @@
r.mapcalc
Raster map calculator.
Raster (r.*)
ParameterMultipleInput|maps|Raster maps used in the calculator|3|True
ParameterString|expression|Expression to evaluate. The raster names used in expression should be the same than in QGIS|None|True|True
ParameterFile|file|File containing expression(s) to evaluate (same rule for raster names than above)|True
ParameterString|seed|Integer seed for rand() function|None|False|True
*ParameterBoolean|-s|Generate random seed (result is non-deterministic)|False
OutputDirectory|output_dir|Results Directory

View File

@ -0,0 +1,8 @@
r.mask
r.mask.rast - Creates a MASK for limiting raster operation.
Raster (r.*)
ParameterRaster|raster|Name of raster map to use as mask|False
ParameterRaster|input|Name of raster map to which apply the mask|False
ParameterString|maskcats|Raster values to use for mask. Format: 1 2 3 thru 7 *|*|False|True
*ParameterBoolean|-i|Create inverse mask|False|True
OutputRaster|output|Masked

View File

@ -0,0 +1,9 @@
r.mask
r.mask.vect - Creates a MASK for limiting raster operation with a vector layer.
Raster (r.*)
ParameterVector|vector|Name of vector map to use as mask|1,2|False
ParameterRaster|input|Name of raster map to which apply the mask|False
*ParameterString|cats|Category values. Example: 1,3,7-9,13|None|False|True
*ParameterString|where|WHERE conditions of SQL statement without 'where' keyword|None|True|True
*ParameterBoolean|-i|Create inverse mask|False|True
OutputRaster|output|Masked

View File

@ -0,0 +1,10 @@
r.random.surface
Generates random surface(s) with spatial dependence.
Raster (r.*)
ParameterNumber|distance|Maximum distance of spatial correlation|0.0|None|0.0|True
ParameterNumber|exponent|Distance decay exponent|0.0|None|1.0|True
ParameterNumber|flat|Distance filter remains flat before beginning exponent|0.0|None|0.0|True
ParameterString|seed|Integer random seed (SEED_MIN >= value >= SEED_MAX), default [random]|None|False|True
ParameterNumber|high|Maximum cell value of distribution|0|None|255|True
ParameterBoolean|-u|Uniformly distributed cell values|False|True
OutputRaster|output|Random_Surface

View File

@ -0,0 +1,8 @@
r.regression.multi
Calculates multiple linear regression from raster maps.
Raster (r.*)
ParameterRaster|mapx|Map for x coefficient|False
ParameterRaster|mapy|Map for y coefficient|False
OutputRaster|residual|Residual Map
OutputRaster|estimates|Estimates Map
OutputHTML|html|Regression coefficients

View File

@ -0,0 +1,14 @@
r.resamp.bspline
Performs bilinear or bicubic spline interpolation with Tykhonov regularization.
Raster (r.*)
ParameterRaster|input|Input raster layer|False
ParameterRaster|mask|Name of raster map to use for masking. Only cells that are not NULL and not zero are interpolated|True
ParameterSelection|method|Sampling interpolation method|bilinear;bicubic|1|False
ParameterString|ew_step|Length (float) of each spline step in the east-west direction|None|False|True
ParameterString|ns_step|Length (float) of each spline step in the north-south direction|None|False|True
ParameterNumber|lambda|Tykhonov regularization parameter (affects smoothing)|0.0|None|0.01|True
ParameterNumber|memory|Maximum memory to be used (in MB). Cache size for raster rows|10|None|300|True
*ParameterBoolean|-n|Only interpolate null cells in input raster map|False|True
*ParameterBoolean|-c|Find the best Tykhonov regularizing parameter using a "leave-one-out" cross validation method|False|True
OutputRaster|output|Resampled BSpline
OutputVector|grid|Interpolation Grid

View File

@ -0,0 +1,10 @@
r.resamp.filter
Resamples raster map layers using an analytic kernel.
Raster (r.*)
ParameterRaster|input|Input raster layer|False
ParameterString|filter|Filter kernel(s) (comma separated list if multiple). Options: box, bartlett, gauss, normal, hermite, sinc, lanczos1, lanczos2, lanczos3, hann, hamming, blackman|None|False
ParameterString|radius|Filter radius for each filter (comma separated list of float if multiple)|None|False|True
ParameterString|x_radius|Filter radius (horizontal) for each filter (comma separated list of float if multiple)|None|False|True
ParameterString|y_radius|Filter radius (vertical) for each filter (comma separated list of float if multiple)|None|False|True
*ParameterBoolean|-n|Propagate NULLs|False|True
OutputRaster|output|Resampled Filter

View File

@ -0,0 +1,7 @@
r.rgb
Splits a raster map into red, green and blue maps.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
OutputRaster|red|Red
OutputRaster|green|Green
OutputRaster|blue|Blue

View File

@ -0,0 +1,17 @@
r.ros
Generates rate of spread raster maps.
Raster (r.*)
ParameterRaster|model|Raster map containing fuel models|False
ParameterRaster|moisture_1h|Raster map containing the 1-hour fuel moisture (%)|True
ParameterRaster|moisture_10h|Raster map containing the 10-hour fuel moisture (%)|True
ParameterRaster|moisture_100h|Raster map containing the 100-hour fuel moisture (%)|True
ParameterRaster|moisture_live|Raster map containing live fuel moisture (%)|False
ParameterRaster|velocity|Raster map containing midflame wind velocities (ft/min)|True
ParameterRaster|direction|Name of raster map containing wind directions (degree)|True
ParameterRaster|slope|Name of raster map containing slope (degree)|True
ParameterRaster|aspect|Raster map containing aspect (degree, CCW from E)|True
ParameterRaster|elevation|Raster map containing elevation (m, required for spotting)|True
OutputRaster|base_ros|Base ROS
OutputRaster|max_ros|Max ROS
OutputRaster|direction_ros|Direction ROS
OutputRaster|spotting_distance|Spotting Distance

View File

@ -0,0 +1,12 @@
r.series.accumulate
Makes each output cell value an accumulation function of the values assigned to the corresponding cells in the input raster map layers.
Raster (r.*)
ParameterMultipleInput|input|Input raster layer(s)|3.0|False
ParameterSelection|method|This method will be applied to compute the accumulative values from the input maps|gdd;bedd;huglin;mean|0
ParameterNumber|scale|Scale factor for input|0.0|None|1.0|True
ParameterNumber|shift|Shift factor for input|0.0|None|0.0|True
ParameterString|range|Ignore values outside this range (min,max)|-10000000000,10000000000|False|True
ParameterString|limits|Lower and upper accumulation limits (lower,upper)|10,30|False|True
ParameterBoolean|-n|Propagate NULLs|False
*ParameterBoolean|-f|Create a FCELL map (floating point single precision) as output|False
OutputRaster|output|Accumulated

View File

@ -0,0 +1,11 @@
r.series.interp
Interpolates raster maps located (temporal or spatial) in between input raster maps at specific sampling positions.
Raster (r.*)
ParameterMultipleInput|input|Input raster layer(s)|3.0|False
ParameterString|datapos|Data point position for each input map|None|True|True
ParameterFile|infile|Input file with one input raster map name and data point position per line, field separator between name and sample point is '|'|True
ParameterString|output|Name for output raster map (comma separated list if multiple|None|False|True
ParameterString|samplingpos|Sampling point position for each output map (comma separated list)|None|True|True
ParameterFile|outfile|Input file with one output raster map name and sample point position per line, field separator between name and sample point is '|'|True
ParameterSelection|method|Interpolation method, currently only linear interpolation is supported|linear|0
OutputDirectory|output_dir|Interpolated rasters

View File

@ -0,0 +1,9 @@
r.shade
Drapes a color raster over an shaded relief or aspect map.
Raster (r.*)
ParameterRaster|shade|Name of shaded relief or aspect raster map|False
ParameterRaster|color|Name of raster to drape over relief raster map|False
ParameterNumber|brighten|Percent to brighten|-99|99|0|True
ParameterString|bgcolor|Color to use instead of NULL values. Either a standard color name, R:G:B triplet, or "none"|None|False|True
*ParameterBoolean|-c|Use colors from color tables for NULL values|False
OutputRaster|output|Shaded

View File

@ -0,0 +1,31 @@
r.solute.transport
Numerical calculation program for transient, confined and unconfined solute transport in two dimensions
Raster (r.*)
ParameterRaster|c|The initial concentration in [kg/m^3]|False
ParameterRaster|phead|The piezometric head in [m]|False
ParameterRaster|hc_x|The x-part of the hydraulic conductivity tensor in [m/s]|False
ParameterRaster|hc_y|The y-part of the hydraulic conductivity tensor in [m/s]|False
ParameterRaster|status|The status for each cell, = 0 - inactive cell, 1 - active cell, 2 - dirichlet- and 3 - transfer boundary condition|False
ParameterRaster|diff_x|The x-part of the diffusion tensor in [m^2/s]|False
ParameterRaster|diff_y|The y-part of the diffusion tensor in [m^2/s]|False
ParameterRaster|q|Groundwater sources and sinks in [m^3/s]|True
ParameterRaster|cin|Concentration sources and sinks bounded to a water source or sink in [kg/s]|True
ParameterRaster|cs|Concentration of inner sources and inner sinks in [kg/s] (i.e. a chemical reaction)|False
ParameterRaster|rd|Retardation factor [-]|False
ParameterRaster|nf|Effective porosity [-]|False
ParameterRaster|top|Top surface of the aquifer in [m]|False
ParameterRaster|bottom|Bottom surface of the aquifer in [m]|False
ParameterRaster|vx|Calculate and store the groundwater filter velocity vector part in x direction [m/s]|True
ParameterRaster|vy|Calculate and store the groundwater filter velocity vector part in y direction [m/s]|True
ParameterNumber|dtime|Calculation time (in seconds)|0.0|None|86400.0|True
ParameterNumber|maxit|Maximum number of iteration used to solve the linear equation system|1|None|10000|True
ParameterNumber|error|Error break criteria for iterative solver|0.0|None|0.000001|True
ParameterSelection|solver|The type of solver which should solve the linear equation system|gauss;lu;jacobi;sor;bicgstab|4
ParameterNumber|relax|The relaxation parameter used by the jacobi and sor solver for speedup or stabilizing|0.0|None|1.0|True
ParameterNumber|al|The longditudinal dispersivity length. [m]|0.0|None|0.0|True
ParameterNumber|at|The transversal dispersivity length. [m]|0.0|None|0.0|True
ParameterNumber|loops|Use this number of time loops if the CFL flag is off. The timestep will become dt/loops.|0.0|None|1.0|True
ParameterSelection|stab|Set the flow stabilizing scheme (full or exponential upwinding).|full;exp|0
*ParameterBoolean|-c|Use the Courant-Friedrichs-Lewy criteria for time step calculation|False
*ParameterBoolean|-f|Use a full filled quadratic linear equation system, default is a sparse linear equation system.|False
OutputRaster|output|Solute Transport

View File

@ -0,0 +1,21 @@
r.spread
Simulates elliptically anisotropic spread.
Raster (r.*)
ParameterRaster|base_ros|Raster map containing base ROS (cm/min)|False
ParameterRaster|max_ros|Raster map containing maximal ROS (cm/min)|False
ParameterRaster|direction_ros|Raster map containing directions of maximal ROS (degree)|False
ParameterRaster|start|Raster map containing starting sources|False
ParameterRaster|spotting_distance|Raster map containing maximal spotting distance (m, required with -s)|True
ParameterRaster|wind_speed|Raster map containing midflame wind speed (ft/min, required with -s)|True
ParameterRaster|fuel_moisture|Raster map containing fine fuel moisture of the cell receiving a spotting firebrand (%, required with -s)|True
ParameterRaster|backdrop|Name of raster map as a display backdrop|True
ParameterSelection|least_size|Basic sampling window size needed to meet certain accuracy (3)|3;5;7;9;11;13;15|0
ParameterNumber|comp_dens|Sampling density for additional computing (range: 0.0 - 1.0 (0.5))|0.0|1.0|0.5|True
ParameterNumber|init_time|Initial time for current simulation (0) (min)|0|None|0|True
ParameterNumber|lag|Simulating time duration LAG (fill the region) (min)|0|None|0|True
*ParameterBoolean|-s|Consider spotting effect (for wildfires)|False
*ParameterBoolean|-i|Use start raster map values in output spread time raster map|False
OutputRaster|output|Spread Time
OutputRaster|x_output|X Back Coordinates
OutputRaster|y_output|Y Back Coordinates

View File

@ -0,0 +1,12 @@
r.stats.quantile
r.stats.quantile.out - Compute category quantiles using two passes and output statistics
Raster (r.*)
ParameterRaster|base|Name of base raster map|False
ParameterRaster|cover|Name of cover raster map|False
ParameterString|quantiles|Number of quantiles|None|False|True
ParameterString|percentiles|List of percentiles|None|False|True
ParameterNumber|bins|Number of bins to use|0|None|1000|True
*ParameterBoolean|-r|Create reclass map with statistics as category labels|False
Hardcoded|-p
OutputFile|output|Statistics File

View File

@ -0,0 +1,11 @@
r.stats.quantile
r.stats.quantile.rast - Compute category quantiles using two passes and output rasters.
Raster (r.*)
ParameterRaster|base|Name of base raster map|False
ParameterRaster|cover|Name of cover raster map|False
ParameterNumber|quantiles|Number of quantiles|2|None|2|True
ParameterString|percentiles|List of percentiles|None|False|True
ParameterNumber|bins|Number of bins to use|0|None|1000|True
*ParameterBoolean|-r|Create reclass map with statistics as category labels|False
OutputDirectory|output_dir|Output Directory

View File

@ -0,0 +1,16 @@
r.sunhours
Calculates solar elevation, solar azimuth, and sun hours.
Raster (r.*)
ParameterNumber|year|Year|1950|2050|2016|False
ParameterNumber|month|Month|1|12|1|True
ParameterNumber|day|Day|1|31|1|False
ParameterNumber|hour|Hour|0|24|12|True
ParameterNumber|minute|Minutes|0|60|0|True
ParameterNumber|second|Seconds|0|60|0|True
ParameterString|percentile|Percentile to calculate (comma separated list if multiple) (requires extended statistics flag)|None|False|True
ParameterString|separator|Field separator. Special characters: pipe, comma, space, tab, newline|None|False|True
*ParameterBoolean|-t|Time is local sidereal time, not Greenwich standard time|False
*ParameterBoolean|-s|Do not use SOLPOS algorithm of NREL|False
OutputRaster|elevation|Solar Elevation Angle
OutputRaster|azimuth|Solar Azimuth Angle
OutputRaster|sunhour|Sunshine Hours

View File

@ -0,0 +1,14 @@
r.support
Allows creation and/or modification of raster map layer support files (metadata).
Raster (r.*)
ParameterRaster|map|Name of raster map|False
ParameterString|title|Title for resultant raster map|None|False|True
ParameterString|timestamp|r.timestamp date: Datetime, datetime1/datetime2, or 'none' to remove'|None|False|True
ParameterString|history|Text to append to the next line of the map's metadata file|None|True|True
ParameterString|units|Text to use for map data units|None|False|True
ParameterString|vdatum|Text to use for map vertical datum|None|False|True
ParameterString|source1|Text to use for data source, line 1|None|False|True
ParameterString|source2|Text to use for data source, line 2|None|False|True
ParameterString|description|Text to use for data description or keyword(s)|None|False|True
*ParameterFile|loadhistory|Text file from which to load history|False
OutputRaster|output|Metadata

View File

@ -0,0 +1,6 @@
r.surf.fractal
Creates a fractal surface of a given fractal dimension.
Raster (r.*)
ParameterNumber|dimension|Fractal dimension of surface (2 < D < 3)|2.0|3.0|2.05|True
ParameterNumber|number|Number of intermediate images to produce|0|None|0|True
OutputRaster|output|Fractal Surface

View File

@ -0,0 +1,10 @@
r.texture
Generate images with textural features from a raster map.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|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
ParameterNumber|size|The size of moving window (odd and >= 3)|3.0|None|3.0|True
ParameterNumber|distance|The distance between two samples (>= 1)|1.0|None|1.0|True
*ParameterBoolean|-s|Separate output for each angle (0, 45, 90, 135)|False
*ParameterBoolean|-a|Calculate all textural measurements|False
OutputDirectory|output|Texture files directory

View File

@ -0,0 +1,8 @@
r.tile
Splits a raster map into tiles
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterString|output|Output base name of rasters|None|False|False
ParameterNumber|width|Width of tiles (columns)|1|None|1024|True
ParameterNumber|height|Height of tiles (rows)|1|None|1024|True
OutputDirectory|output_dir|Tiles Directory

View File

@ -0,0 +1,14 @@
r.tileset
Produces tilings of the source projection for use in the destination region and projection.
Raster (r.*)
ParameterString|sourceproj|Source projection|None|True|False
ParameterString|sourcescale|Conversion factor from units to meters in source projection|1|False|True
ParameterString|destproj|Destination projection|None|True|False
ParameterString|destscale|Conversion factor from units to meters in destination projection|1|False|True
ParameterNumber|maxcols|Maximum number of columns for a tile in the source projection|1|None|1024|True
ParameterNumber|maxrows|Maximum number of rows for a tile in the source projection|1|None|1024|True
ParameterNumber|overlap|Number of cells tiles should overlap in each direction|0|None|0|True
ParameterString|separator|Output field separator|None|False|True
*ParameterBoolean|-g|Produces shell script output|False
*ParameterBoolean|-w|Produces web map server query string output|False
OutputFile|output|Tileset

View File

@ -0,0 +1,7 @@
r.topmodel
r.topmodel.topidxstats - Builds a TOPMODEL topographic index statistics file.
Raster (r.*)
ParameterRaster|topidx|Name of input topographic index raster map|False
ParameterNumber|ntopidxclasses|Number of topographic index classes|0|None|30|True
Hardcoded|-p
OutputFile|outtopidxstats|TOPMODEL topographic index statistics file

View File

@ -0,0 +1,9 @@
r.topmodel
Simulates TOPMODEL which is a physically based hydrologic model.
Raster (r.*)
ParameterFile|parameters|Name of TOPMODEL parameters file|False|False
ParameterFile|topidxstats|Name of topographic index statistics file|False|False
ParameterFile|input|Name of rainfall and potential evapotranspiration data file|False|False
ParameterString|timestep|Time step. Generate output for this time step|None|False|True
ParameterString|topidxclass|Topographic index class. Generate output for this topographic index class|None|False|True
OutputFile|output|TOPMODEL output

View File

@ -0,0 +1,9 @@
r.transect
Outputs raster map layer values lying along user defined transect line(s).
Raster (r.*)
ParameterRaster|map|Raster map to be queried|False
ParameterString|line|Transect definition: east,north,azimuth,distance[,east,north,azimuth,distance,...]|None|False|False
ParameterString|null_value|String representing NULL value|*|False|True
*ParameterBoolean|-g|Output easting and northing in first two columns of four column output|False
OutputFile|output|Transect file

View File

@ -0,0 +1,10 @@
r.univar
Calculates univariate statistics from the non-null cells of a raster map.
Raster (r.*)
ParameterMultipleInput|map|Name of raster map(s)|3|False
ParameterRaster|zones|Raster map used for zoning, must be of type CELL|True
ParameterString|percentile|Percentile to calculate (comma separated list if multiple) (requires extended statistics flag)|None|False|True
ParameterString|separator|Field separator. Special characters: pipe, comma, space, tab, newline|None|False|True
*ParameterBoolean|-e|Calculate extended statistics|False
Hardcoded|-t
OutputFile|output|Univariate results

View File

@ -0,0 +1,8 @@
r.uslek
Computes USLE Soil Erodibility Factor (K).
Raster (r.*)
ParameterRaster|psand|Name of soil sand fraction raster map [0.0-1.0]|False
ParameterRaster|pclay|Name of soil clay fraction raster map [0.0-1.0]|False
ParameterRaster|psilt|Name of soil silt fraction raster map [0.0-1.0]|False
ParameterRaster|pomat|Name of soil organic matter raster map [0.0-1.0]|False
OutputRaster|output|USLE R Raster

View File

@ -0,0 +1,6 @@
r.usler
Computes USLE R factor, Rainfall erosivity index.
Raster (r.*)
ParameterRaster|input|Name of annual precipitation raster map [mm/year]|False
ParameterSelection|method|Name of USLE R equation|roose;morgan;foster;elswaify|0
OutputRaster|output|USLE R Raster

View File

@ -0,0 +1,17 @@
r.walk
r.walk.coords - Creates a raster map showing the anisotropic cumulative cost of moving between different geographic locations on an input raster map whose cell category values represent cost from a list of coordinates.
Raster (r.*)
ParameterRaster|elevation|Name of input elevation raster map|False
ParameterRaster|friction|Name of input raster map containing friction costs|False
ParameterString|start_coordinates|Coordinates of starting point(s) (a list of E,N)|None|False|False
ParameterString|stop_coordinates|Coordinates of stopping point(s) (a list of E,N)|None|False|True
ParameterString|walk_coeff|Coefficients for walking energy formula parameters a,b,c,d|0.72,6.0,1.9998,-1.9998|False|True
ParameterNumber|lambda|Lambda coefficients for combining walking energy and friction cost|None|None|1.0|True
ParameterNumber|slope_factor|Slope factor determines travel energy cost per height step|None|None|-0.2125|True
ParameterNumber|max_cost|Maximum cumulative cost|None|None|0.0|True
ParameterNumber|null_cost|Cost assigned to null cells. By default, null cells are excluded|None|None|None|True
*ParameterNumber|memory|Maximum memory to be used in MB|0|None|300|True
*ParameterBoolean|-k|Use the 'Knight's move'; slower, but more accurate|False
*ParameterBoolean|-n|Keep null values in output raster layer|False
OutputRaster|output|Cumulative cost
OutputRaster|outdir|Movement Directions

View File

@ -0,0 +1,17 @@
r.walk
r.walk.points - Creates a raster map showing the anisotropic cumulative cost of moving between different geographic locations on an input raster map whose cell category values represent cost from point vector layers.
Raster (r.*)
ParameterRaster|elevation|Name of input elevation raster map|False
ParameterRaster|friction|Name of input raster map containing friction costs|False
ParameterVector|start_points|Start points|0|False
ParameterVector|stop_points|Stop points|0|True
ParameterString|walk_coeff|Coefficients for walking energy formula parameters a,b,c,d|0.72,6.0,1.9998,-1.9998|False|True
ParameterNumber|lambda|Lambda coefficients for combining walking energy and friction cost|None|None|1.0|True
ParameterNumber|slope_factor|Slope factor determines travel energy cost per height step|None|None|-0.2125|True
ParameterNumber|max_cost|Maximum cumulative cost|None|None|0.0|True
ParameterNumber|null_cost|Cost assigned to null cells. By default, null cells are excluded|None|None|None|True
*ParameterNumber|memory|Maximum memory to be used in MB|0|None|300|True
*ParameterBoolean|-k|Use the 'Knight's move'; slower, but more accurate|False
*ParameterBoolean|-n|Keep null values in output raster layer|False
OutputRaster|output|Cumulative cost
OutputRaster|outdir|Movement Directions

View File

@ -0,0 +1,16 @@
r.walk
r.walk.rast - Creates a raster map showing the anisotropic cumulative cost of moving between different geographic locations on an input raster map whose cell category values represent cost from a raster.
Raster (r.*)
ParameterRaster|elevation|Name of input elevation raster map|False
ParameterRaster|friction|Name of input raster map containing friction costs|False
ParameterRaster|start_raster|Name of starting raster points map (all non-NULL cells are starting points)|False
ParameterString|walk_coeff|Coefficients for walking energy formula parameters a,b,c,d|0.72,6.0,1.9998,-1.9998|False|True
ParameterNumber|lambda|Lambda coefficients for combining walking energy and friction cost|None|None|1.0|True
ParameterNumber|slope_factor|Slope factor determines travel energy cost per height step|None|None|-0.2125|True
ParameterNumber|max_cost|Maximum cumulative cost|None|None|0.0|True
ParameterNumber|null_cost|Cost assigned to null cells. By default, null cells are excluded|None|None|None|True
*ParameterNumber|memory|Maximum memory to be used in MB|0|None|300|True
*ParameterBoolean|-k|Use the 'Knight's move'; slower, but more accurate|False
*ParameterBoolean|-n|Keep null values in output raster layer|False
OutputRaster|output|Cumulative cost
OutputRaster|outdir|Movement Directions

View File

@ -1,15 +0,0 @@
r.walk
Outputs a raster layer showing the anisotropic cumulative cost of moving based on friction cost.
Raster (r.*)
ParameterRaster|elevation|Elevation raster layer|False
ParameterRaster|friction|Friction costs layer|False
ParameterVector|start_points|Starting points|-1|False
ParameterString|max_cost|An optional maximum cumulative cost|0
ParameterString|percent_memory|Percent of map to keep in memory|100
*ParameterString|walk_coeff|Coefficients for walking energy formula parameters a,b,c,d|0.72,6.0,1.9998,-1.9998
*ParameterString|lambda|Lambda coefficients for combining walking energy and friction cost|1.0
ParameterString|slope_factor|Slope factor determines travel energy cost per height step|-0.2125
*ParameterBoolean|-k|Use the 'Knight's move'; slower, but more accurate|True
*ParameterBoolean|-n|Keep null values in output map|True
*ParameterBoolean|-r|Start with values in raster map|True
OutputRaster|output|Cost

View File

@ -0,0 +1,8 @@
r.what.color
Queries colors for a raster map layer.
Raster (r.*)
ParameterRaster|input|Raster map to query colors|False
ParameterString|value|Values to query colors for (comma separated list)|None|False|False
ParameterString|format|Output format (printf-style)|None|False|True
OutputFile|output|Colors file

View File

@ -0,0 +1,14 @@
r.what
r.what.coords - Queries raster maps on their category values and category labels on a point.
Raster (r.*)
ParameterRaster|map|Name of raster map|False
ParameterString|coordinates|Coordinates for query (east, north)|None|False|False
ParameterString|null_value|String representing NULL value|*|False|True
ParameterString|separator|Field separator. Special characters: pipe, comma, space, tab, newlineString representing NULL value|pipe|False|True
ParameterNumber|cache|Size of point cache|0|None|500|True
*ParameterBoolean|-n|Output header row|False|True
*ParameterBoolean|-f|Show the category labels of the grid cell(s)|False|True
*ParameterBoolean|-r|Output color values as RRR:GGG:BBB|False|True
*ParameterBoolean|-i|Output integer category values, not cell values|False|True
*ParameterBoolean|-c|Turn on cache reporting|False|True
OutputFile|output|Raster Value File

View File

@ -0,0 +1,14 @@
r.what
r.what.points - Queries raster maps on their category values and category labels on a layer of points.
Raster (r.*)
ParameterRaster|map|Name of raster map|False
ParameterVector|points|Name of vector points layer for query|0|False
ParameterString|null_value|String representing NULL value|*|False|True
ParameterString|separator|Field separator. Special characters: pipe, comma, space, tab, newlineString representing NULL value|pipe|False|True
ParameterNumber|cache|Size of point cache|0|None|500|True
*ParameterBoolean|-n|Output header row|False|True
*ParameterBoolean|-f|Show the category labels of the grid cell(s)|False|True
*ParameterBoolean|-r|Output color values as RRR:GGG:BBB|False|True
*ParameterBoolean|-i|Output integer category values, not cell values|False|True
*ParameterBoolean|-c|Turn on cache reporting|False|True
OutputFile|output|Raster Values File

View File

@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_blend.py
----------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
def processInputs(alg):
# If there is another raster to copy categories from
# we need to import it with r.in.gdal rather than r.external
first = alg.getParameterValue(u'first')
second = alg.getParameterValue(u'second')
if first in alg.exportedLayers.keys() and second in alg.exportedLayers.keys():
return
for raster in [first, second]:
alg.setSessionProjectionFromLayer(raster, alg.commands)
destFilename = alg.getTempFilename()
alg.exportedLayers[raster] = destFilename
command = 'r.in.gdal input={} output={} --overwrite -o'.format(raster, destFilename)
alg.commands.append(command)
alg.setSessionProjectionFromProject(alg.commands)
region = unicode(alg.getParameterValue(alg.GRASS_REGION_EXTENT_PARAMETER))
regionCoords = region.split(',')
command = 'g.region'
command += ' -a'
command += ' n=' + unicode(regionCoords[3])
command += ' s=' + unicode(regionCoords[2])
command += ' e=' + unicode(regionCoords[1])
command += ' w=' + unicode(regionCoords[0])
cellsize = alg.getParameterValue(alg.GRASS_REGION_CELLSIZE_PARAMETER)
if cellsize:
command += ' res=' + unicode(cellsize)
else:
command += ' res=' + unicode(alg.getDefaultCellsize())
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
alg.commands.append(command)
def processOutputs(alg):
# Keep color table
output = alg.getOutputValue(u'output')
command = u"r.out.gdal -t createopt=\"TFW=YES,COMPRESS=LZW\" input={} output=\"{}\" --overwrite".format(
alg.exportedLayers[output],
output
)
alg.commands.append(command)
alg.outputCommands.append(command)

View File

@ -0,0 +1,95 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_blend_rgb.py
--------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from processing.core.outputs import getOutputFromString
def processInputs(alg):
# If there is another raster to copy categories from
# we need to import it with r.in.gdal rather than r.external
first = alg.getParameterValue(u'first')
second = alg.getParameterValue(u'second')
if first in alg.exportedLayers.keys() and second in alg.exportedLayers.keys():
return
for raster in [first, second]:
alg.setSessionProjectionFromLayer(raster, alg.commands)
destFilename = alg.getTempFilename()
alg.exportedLayers[raster] = destFilename
command = 'r.in.gdal input={} output={} --overwrite -o'.format(raster, destFilename)
alg.commands.append(command)
alg.setSessionProjectionFromProject(alg.commands)
region = unicode(alg.getParameterValue(alg.GRASS_REGION_EXTENT_PARAMETER))
regionCoords = region.split(',')
command = 'g.region'
command += ' -a'
command += ' n=' + unicode(regionCoords[3])
command += ' s=' + unicode(regionCoords[2])
command += ' e=' + unicode(regionCoords[1])
command += ' w=' + unicode(regionCoords[0])
cellsize = alg.getParameterValue(alg.GRASS_REGION_CELLSIZE_PARAMETER)
if cellsize:
command += ' res=' + unicode(cellsize)
else:
command += ' res=' + unicode(alg.getDefaultCellsize())
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
alg.commands.append(command)
def processCommand(alg):
# We need to remove all outputs
basename = getOutputFromString('OutputRaster|output|Output basename')
basename.value = 'output'
alg.addOutput(basename)
outputNames = ['output_{}'.format(f) for f in ['red', 'green', 'blue']]
outputs = [alg.getOutputFromName(f) for f in outputNames]
for output in outputNames:
alg.exportedLayers[alg.getOutputValue(output)] = 'output' + alg.uniqueSufix
alg.removeOutputFromName(output)
alg.processCommand()
# And to re-add them
alg.removeOutputFromName('output')
for output in outputs:
alg.addOutput(output)
def processOutputs(alg):
# Export each color raster
colors = ['red', 'green', 'blue']
for color in colors:
output = alg.getOutputValue('output_{}'.format(color))
command = "r.out.gdal input={} output=\"{}\" createopt=\"TFW=YES,COMPRESS=LZW\"".format(
alg.exportedLayers[output] + '.' + color[0], output)
alg.commands.append(command)
alg.outputCommands.append(command)

View File

@ -0,0 +1,120 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_category.py
-------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import codecs
from processing.tools.system import getTempFilename
def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
rules = alg.getParameterValue(u'rules')
txtrules = alg.getParameterValue(u'txtrules')
raster = alg.getParameterValue(u'raster')
if rules and txtrules:
return alg.tr("You need to set either a rules file or write directly the rules !")
elif (rules and raster) or (txtrules and raster):
return alg.tr("You need to set either rules or a raster from which to copy categories !")
return None
def processInputs(alg):
# If there is another raster to copy categories from
# we need to import it with r.in.gdal rather than r.external
inputRaster = alg.getParameterValue(u'map')
copyRaster = alg.getParameterValue(u'raster')
if copyRaster:
if copyRaster in alg.exportedLayers.keys():
return
for raster, method in (inputRaster, 'r.external'), (copyRaster, 'r.in.gdal'):
alg.setSessionProjectionFromLayer(raster, alg.commands)
destFilename = alg.getTempFilename()
alg.exportedLayers[raster] = destFilename
command = '{} input={} output={} band=1 --overwrite -o'.format(method, raster, destFilename)
alg.commands.append(command)
alg.setSessionProjectionFromProject(alg.commands)
region = unicode(alg.getParameterValue(alg.GRASS_REGION_EXTENT_PARAMETER))
regionCoords = region.split(',')
command = 'g.region'
command += ' -a'
command += ' n=' + unicode(regionCoords[3])
command += ' s=' + unicode(regionCoords[2])
command += ' e=' + unicode(regionCoords[1])
command += ' w=' + unicode(regionCoords[0])
cellsize = alg.getParameterValue(alg.GRASS_REGION_CELLSIZE_PARAMETER)
if cellsize:
command += ' res=' + unicode(cellsize)
else:
command += ' res=' + unicode(alg.getDefaultCellsize())
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
alg.commands.append(command)
else:
alg.processInputs()
def processCommand(alg):
# We temporary remove the output
out = alg.getOutputFromName('output')
mapParam = alg.getParameterValue('map')
alg.exportedLayers[out.value] = alg.exportedLayers[mapParam]
alg.removeOutputFromName('output')
txtRulesParam = alg.getParameterFromName(u'txtrules')
rules = alg.getParameterFromName(u'rules')
# Handle inline rules
if txtRulesParam.value:
# Creates a temporary txt file
tempRulesName = getTempFilename('txt')
# Inject rules into temporary txt file
with codecs.open(tempRulesName, 'w', 'utf-8') as tempRules:
tempRules.write(txtRulesParam.value)
# Replace rules with temporary file
rules.value = tempRulesName
alg.parameters.remove(txtRulesParam)
alg.processCommand()
# We re-add the new output
alg.addOutput(out)
def processOutputs(alg):
# Output results ('from' table and output table)
out = alg.getOutputValue('output')
command = u"r.out.gdal --overwrite -t -c createopt=\"TFW=YES,COMPRESS=LZW\" input={} output=\"{}\"".format(
alg.exportedLayers[out], out)
alg.commands.append(command)
alg.outputCommands.append(command)

View File

@ -0,0 +1,114 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_colors.py
-----------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import os
def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
if alg.getParameterValue('rules_txt') and alg.getParameterValue('rules'):
return alg.tr("You need to set either inline rules or a rules file !")
return None
def processInputs(alg):
# import all rasters with their color tables (and their bands)
# We need to import all the bands and color tables of the input rasters
rasters = alg.getParameterValue('map').split(',')
for raster in rasters:
if raster in alg.exportedLayers.keys():
continue
alg.setSessionProjectionFromLayer(raster, alg.commands)
destFilename = alg.getTempFilename()
alg.exportedLayers[raster] = destFilename
command = 'r.in.gdal input={} output={} --overwrite -o'.format(raster, destFilename)
alg.commands.append(command)
alg.setSessionProjectionFromProject(alg.commands)
region = unicode(alg.getParameterValue(alg.GRASS_REGION_EXTENT_PARAMETER))
regionCoords = region.split(',')
command = 'g.region'
command += ' -a'
command += ' n=' + unicode(regionCoords[3])
command += ' s=' + unicode(regionCoords[2])
command += ' e=' + unicode(regionCoords[1])
command += ' w=' + unicode(regionCoords[0])
cellsize = alg.getParameterValue(alg.GRASS_REGION_CELLSIZE_PARAMETER)
if cellsize:
command += ' res=' + unicode(cellsize)
else:
command += ' res=' + unicode(alg.getDefaultCellsize())
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
alg.commands.append(command)
def processCommand(alg):
# remove output before processCommand
output = alg.getOutputFromName('output_dir')
alg.removeOutputFromName('output_dir')
color = alg.getParameterFromName('color')
if color.value == 0:
alg.parameters.remove(color)
# Handle rules
txtRules = alg.getParameterFromName('rules_txt')
if txtRules.value:
# Creates a temporary txt file
tempRulesName = alg.getTempFilename()
# Inject rules into temporary txt file
with open(tempRulesName, "w") as tempRules:
tempRules.write(txtRules.value)
# Use temporary file as rules file
alg.setParameterValue('rules', tempRulesName)
alg.parameters.remove(txtRules)
alg.processCommand()
# re-add the previous output
alg.addOutput(output)
alg.addParameter(color)
alg.addParameter(txtRules)
def processOutputs(alg):
# Export all rasters with their color tables (and their bands)
rasters = [alg.exportedLayers[f] for f in alg.getParameterValue('map').split(',')]
output_dir = alg.getOutputValue('output_dir')
for raster in rasters:
command = u"r.out.gdal -t createopt=\"TFW=YES,COMPRESS=LZW\" input={} output=\"{}\" --overwrite".format(
raster,
os.path.join(output_dir, raster + '.tif')
)
alg.commands.append(command)
alg.outputCommands.append(command)

View File

@ -0,0 +1,80 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_colors_stddev.py
------------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
def processInputs(alg):
# We need to import all the bands and to preserve color table
raster = alg.getParameterValue('map')
if raster in alg.exportedLayers.keys():
return
alg.setSessionProjectionFromLayer(raster, alg.commands)
destFilename = alg.getTempFilename()
alg.exportedLayers[raster] = destFilename
command = 'r.in.gdal input={} output={} --overwrite -o'.format(raster, destFilename)
alg.commands.append(command)
alg.setSessionProjectionFromProject(alg.commands)
region = unicode(alg.getParameterValue(alg.GRASS_REGION_EXTENT_PARAMETER))
regionCoords = region.split(',')
command = 'g.region'
command += ' -a'
command += ' n=' + unicode(regionCoords[3])
command += ' s=' + unicode(regionCoords[2])
command += ' e=' + unicode(regionCoords[1])
command += ' w=' + unicode(regionCoords[0])
cellsize = alg.getParameterValue(alg.GRASS_REGION_CELLSIZE_PARAMETER)
if cellsize:
command += ' res=' + unicode(cellsize)
else:
command += ' res=' + unicode(alg.getDefaultCellsize())
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
alg.commands.append(command)
def processCommand(alg):
# We need to remove output
output = alg.getOutputFromName('output')
alg.exportedLayers[output.value] = output.name + alg.uniqueSufix
alg.removeOutputFromName('output')
alg.processCommand()
alg.addOutput(output)
def processOutputs(alg):
# We need to export the raster with all its bands and its color table
output = alg.getOutputValue('output')
raster = alg.getParameterFromName('map')
# Get the list of rasters matching the basename
command = "r.out.gdal -t input={} output=\"{}\" createopt=\"TFW=YES,COMPRESS=LZW\"".format(
alg.exportedLayers[raster.value], output)
alg.commands.append(command)
alg.outputCommands.append(command)

View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_drain.py
----------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import os
def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
if alg.getParameterValue('start_coordinates') and alg.getParameterValue('start_points'):
return alg.tr("You need to set either start coordinates OR a start points vector layer !")
parameters = [alg.getParameterValue(f) for f in ['-c', '-a', '-n']]
paramscore = [f for f in parameters if f]
if len(paramscore) > 1:
return alg.tr("-c, -a, -n parameters are mutually exclusive !")
return None

View File

@ -0,0 +1,153 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li.py
-------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import shutil
from processing.tools.system import isWindows, isMac, userFolder, mkdir
from processing.core.parameters import getParameterFromString
import os
# for MS-Windows users who have MBCS chars in their name:
if os.name == 'nt':
import win32api
def rliPath():
"""Return r.li GRASS7 user dir"""
if isWindows():
homeDir = win32api.GetShortPathName(os.path.expanduser('~'))
return os.path.join(homeDir, 'AppData', 'Roaming', 'GRASS7', 'r.li')
else:
return os.path.join(os.path.expanduser("~"), '.grass7', 'r.li')
def removeConfigFile(alg):
""" Remove the r.li user dir config file """
configPath = alg.getParameterValue('config')
if isWindows():
command = "DEL {}".format(os.path.join(rliPath(), configPath))
else:
command = "rm {}".format(os.path.join(rliPath(), configPath))
alg.commands.append(command)
def checkMovingWindow(alg, outputTxt=False):
""" Verify if we have the right parameters """
configTxt = alg.getParameterValue('config_txt')
config = alg.getParameterValue('config')
if configTxt and config:
return alg.tr("You need to set either inline configuration or a configuration file !")
# Verify that configuration is in moving window
movingWindow = False
if configTxt:
if 'MOVINGWINDOW' in configTxt:
movingWindow = True
# Read config file:
if config:
with open(config) as f:
for line in f:
if 'MOVINGWINDOW' in line:
movingWindow = True
if not movingWindow and not outputTxt:
return alg.tr('Your configuration needs to be a "moving window" configuration !')
if movingWindow and outputTxt:
return alg.tr('Your configuration needs to be a non "moving window" configuration !')
return None
def configFile(alg, outputTxt=False):
""" Handle inline configuration """
# Where is the GRASS7 user directory ?
userGrass7Path = rliPath()
if not os.path.isdir(userGrass7Path):
mkdir(userGrass7Path)
if not os.path.isdir(os.path.join(userGrass7Path, 'output')):
mkdir(os.path.join(userGrass7Path, 'output'))
origConfigFile = alg.getParameterValue('config')
# Handle inline configuration
configTxt = alg.getParameterFromName('config_txt')
if configTxt.value:
# Creates a temporary txt file in user r.li directory
tempConfig = alg.getTempFilename()
configFilePath = os.path.join(userGrass7Path, tempConfig)
# Inject rules into temporary txt file
with open(configFilePath, "w") as f:
f.write(configTxt.value)
# Use temporary file as rules file
alg.setParameterValue('config', os.path.basename(configFilePath))
alg.parameters.remove(configTxt)
# If we have a configuration file, we need to copy it into user dir
if origConfigFile:
configFilePath = os.path.join(userGrass7Path, os.path.basename(origConfigFile))
# Copy the file
shutil.copy(origConfigFile, configFilePath)
# Change the parameter value
alg.setParameterValue('config', os.path.basename(configFilePath))
origOutput = alg.getOutputFromName('output')
if outputTxt:
param = getParameterFromString("ParameterString|output|txt output|None|False|True")
param.value = os.path.basename(origOutput.value)
alg.addParameter(param)
alg.removeOutputFromName('output')
alg.processCommand()
# Remove Config file:
removeConfigFile(alg)
# re-add configTxt
alg.addParameter(configTxt)
alg.setParameterValue('config', origConfigFile)
if outputTxt:
for param in [f for f in alg.parameters if f.name == 'output']:
alg.parameters.remove(param)
alg.addOutput(origOutput)
def moveOutputTxtFile(alg):
# Find output file name:
origOutput = alg.getOutputValue('output')
userGrass7Path = rliPath()
outputDir = os.path.join(userGrass7Path, 'output')
output = os.path.join(outputDir, os.path.basename(origOutput))
# move the file
if isWindows():
command = "MOVE /Y {} {}".format(output, origOutput)
else:
command = "mv -f {} {}".format(output, origOutput)
alg.commands.append(command)

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_cwed.py
------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile
def checkParameterValuesBeforeExecuting(alg):
checkMovingWindow(alg)
def processCommand(alg):
configFile(alg)

View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_cwed_ascii.py
------------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile, moveOutputTxtFile
def checkParameterValuesBeforeExecuting(alg):
return checkMovingWindow(alg, True)
def processCommand(alg):
configFile(alg, True)
def processOutputs(alg):
moveOutputTxtFile(alg)

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_dominance.py
-----------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile
def checkParameterValuesBeforeExecuting(alg):
return checkMovingWindow(alg)
def processCommand(alg):
configFile(alg)

View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_dominance_ascii.py
-----------------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile, moveOutputTxtFile
def checkParameterValuesBeforeExecuting(alg):
return checkMovingWindow(alg, True)
def processCommand(alg):
configFile(alg, True)
def processOutputs(alg):
moveOutputTxtFile(alg)

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_edgedensity.py
-------------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile
def checkParameterValuesBeforeExecuting(alg):
checkMovingWindow(alg)
def processCommand(alg):
configFile(alg)

View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_edgedensity_ascii.py
-------------------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile, moveOutputTxtFile
def checkParameterValuesBeforeExecuting(alg):
return checkMovingWindow(alg, True)
def processCommand(alg):
configFile(alg, True)
def processOutputs(alg):
moveOutputTxtFile(alg)

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_mpa.py
-----------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile
def checkParameterValuesBeforeExecuting(alg):
checkMovingWindow(alg)
def processCommand(alg):
configFile(alg)

View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_mpa_ascii.py
-----------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile, moveOutputTxtFile
def checkParameterValuesBeforeExecuting(alg):
return checkMovingWindow(alg, True)
def processCommand(alg):
configFile(alg, True)
def processOutputs(alg):
moveOutputTxtFile(alg)

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_mps.py
-----------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile
def checkParameterValuesBeforeExecuting(alg):
checkMovingWindow(alg)
def processCommand(alg):
configFile(alg)

View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_mps_ascii.py
-----------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile, moveOutputTxtFile
def checkParameterValuesBeforeExecuting(alg):
return checkMovingWindow(alg, True)
def processCommand(alg):
configFile(alg, True)
def processOutputs(alg):
moveOutputTxtFile(alg)

View File

@ -0,0 +1,133 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li.py
-------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import shutil
from processing.tools.system import isWindows, isMac, userFolder, mkdir
from os import path
def rliPath():
"""Return r.li GRASS7 user dir"""
if isWindows():
return path.join(userFolder(), 'GRASS7', 'r.li')
else:
return path.join(userFolder(), '.grass7', 'r.li')
def removeConfigFile(alg):
""" Remove the r.li user dir config file """
configPath = alg.getParameterValue('config')
if isWindow():
command = "DEL {}".format(configPath)
else:
command = "rm {}".format(configPath)
alg.commands.append(command)
def checkMovingWindow(alg):
""" Verify if we have the right parameters """
configTxt = alg.getParameterValue('config_txt')
config = alg.getParameterValue('config')
if configTxt and config:
return alg.tr("You need to set either inline configuration or a configuration file !")
# Verify that configuration is in moving window
movingWindow = False
if configTxt and 'MOVINGWINDOW' in configTxt:
movingWindow = True
# Read config file:
if config:
with open(config) as f:
for line in f:
if 'MOVINGWINDOW' in line:
movingWindow = True
if not movingWindow:
return alg.tr('Your configuration needs to be a "moving window" configuration !')
return None
def configFile(alg, outputTxt=False):
""" Handle inline configuration """
# Where is the GRASS7 user directory ?
userGrass7Path = rliPath()
mkdir(userGrass7Path)
origConfigFile = alg.getParameterValue('config')
# Handle inline configuration
configTxt = alg.getParameterFromName('config_txt')
if configTxt.value:
# Creates a temporary txt file in user r.li directory
tempConfig = alg.getTempFilename()
configFilePath = path.join(userGrass7, tempConfig)
# Inject rules into temporary txt file
with open(configFilePath, "w") as f:
f.write(configTxt.value)
# Use temporary file as rules file
alg.setParameterValue('config', configFilePath)
alg.parameters.remove(configTxt)
# If we have a configuration file, we need to copy it into user dir
if origConfigFile:
configFilePath = path.join(userGrass7Path, path.basename(origConfigFile))
# Copy the file
shutil.copy(origConfigFile, configFilePath)
# Change the parameter value
alg.setParameterValue('config', configFilePath)
if outputTxt:
origOutput = alg.getOutputValue('output')
alg.setOutputValue('output', path.basename(origOutput))
alg.processCommand()
# Remove Config file:
removeConfigFile(alg)
# re-add configTxt
alg.addParameter(configTxt)
alg.setParameterValue('config', origConfigFile)
def moveOutputTxtFile(alg):
# Find output file name:
origOutput = alg.getOutputValue('output')
userGrass7Path = rliPath()
outputDir = path.join(userGrass7Path, 'OUTPUT')
output = path.join(outputDir, path.basename(origOutput))
# move the file
if isWindows():
command = "cp {} {}".format(output, origOutput)
else:
command = "mv {} {}".format(output, origOutput)
alg.commands.append(command)

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_padcv.py
-------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile
def checkParameterValuesBeforeExecuting(alg):
checkMovingWindow(alg)
def processCommand(alg):
configFile(alg)

View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_padcv_ascii.py
-------------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile, moveOutputTxtFile
def checkParameterValuesBeforeExecuting(alg):
return checkMovingWindow(alg, True)
def processCommand(alg):
configFile(alg, True)
def processOutputs(alg):
moveOutputTxtFile(alg)

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
r_li_padrange.py
----------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from r_li import checkMovingWindow, configFile
def checkParameterValuesBeforeExecuting(alg):
checkMovingWindow(alg)
def processCommand(alg):
configFile(alg)

Some files were not shown because too many files have changed in this diff Show More