Skip to content

Commit ede5f8f

Browse files
author
Médéric RIBREUX
committedFeb 28, 2016
Add r.mask algorithm
1 parent d5b5c6c commit ede5f8f

File tree

5 files changed

+138
-0
lines changed

5 files changed

+138
-0
lines changed
 
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
r.mask
2+
r.mask.rast - Creates a MASK for limiting raster operation.
3+
Raster (r.*)
4+
ParameterRaster|raster|Name of raster map to use as mask|False
5+
ParameterRaster|input|Name of raster map to which apply the mask|False
6+
ParameterString|maskcats|Raster values to use for mask. Format: 1 2 3 thru 7 *|*|False|True
7+
*ParameterBoolean|-i|Create inverse mask|False|True
8+
OutputRaster|output|Masked
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
r.mask
2+
r.mask.vect - Creates a MASK for limiting raster operation with a vector layer.
3+
Raster (r.*)
4+
ParameterVector|vector|Name of vector map to use as mask|1,2|False
5+
ParameterRaster|input|Name of raster map to which apply the mask|False
6+
*ParameterString|cats|Category values. Example: 1,3,7-9,13|None|False|True
7+
*ParameterString|where|WHERE conditions of SQL statement without 'where' keyword|None|True|True
8+
*ParameterBoolean|-i|Create inverse mask|False|True
9+
OutputRaster|output|Masked
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
r_mask.py
6+
---------
7+
Date : February 2016
8+
Copyright : (C) 2016 by Médéric Ribreux
9+
Email : medspx at medspx dot fr
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Médéric Ribreux'
21+
__date__ = 'February 2016'
22+
__copyright__ = '(C) 2016, Médéric Ribreux'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
29+
def processCommand(alg):
30+
# Remove output and input
31+
clipped = alg.getParameterFromName('input')
32+
out = alg.getOutputFromName('output')
33+
alg.exportedLayers[out.value] = alg.exportedLayers[clipped.value]
34+
alg.removeOutputFromName('output')
35+
alg.parameters.remove(clipped)
36+
37+
alg.processCommand()
38+
39+
# Re-add the output !
40+
alg.addOutput(out)
41+
42+
43+
def processOutputs(alg):
44+
out = alg.getOutputValue('output')
45+
inputRaster = alg.exportedLayers[out]
46+
command = u"r.out.gdal --overwrite -c createopt=\"TFW=YES,COMPRESS=LZW\" input={} output=\"{}\"".format(
47+
inputRaster, out)
48+
alg.commands.append(command)
49+
alg.outputCommands.append(command)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
r_mask_rast.py
6+
--------------
7+
Date : February 2016
8+
Copyright : (C) 2016 by Médéric Ribreux
9+
Email : medspx at medspx dot fr
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Médéric Ribreux'
21+
__date__ = 'February 2016'
22+
__copyright__ = '(C) 2016, Médéric Ribreux'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
import r_mask
29+
30+
31+
def processCommand(alg):
32+
r_mask.processCommand(alg)
33+
34+
35+
def processOutputs(alg):
36+
r_mask.processOutputs(alg)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
r_mask_vect.py
6+
--------------
7+
Date : February 2016
8+
Copyright : (C) 2016 by Médéric Ribreux
9+
Email : medspx at medspx dot fr
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Médéric Ribreux'
21+
__date__ = 'February 2016'
22+
__copyright__ = '(C) 2016, Médéric Ribreux'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
import r_mask
29+
30+
31+
def processCommand(alg):
32+
r_mask.processCommand(alg)
33+
34+
35+
def processOutputs(alg):
36+
r_mask.processOutputs(alg)

0 commit comments

Comments
 (0)