Skip to content

Commit

Permalink
Add r.mask algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
Médéric RIBREUX committed Feb 14, 2016
1 parent 61fc094 commit 6d39ad9
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions python/plugins/processing/algs/grass7/ext/r_mask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
r_mask.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 processCommand(alg):
# Remove output and input
clipped = alg.getParameterFromName('input')
out = alg.getOutputFromName('output')
alg.exportedLayers[out.value] = alg.exportedLayers[clipped.value]
alg.removeOutputFromName('output')
alg.parameters.remove(clipped)

alg.processCommand()

# Re-add the output !
alg.addOutput(out)


def processOutputs(alg):
out = alg.getOutputValue('output')
inputRaster = alg.exportedLayers[out]
command = u"r.out.gdal --overwrite -c createopt=\"TFW=YES,COMPRESS=LZW\" input={} output=\"{}\"".format(
inputRaster, out)
alg.commands.append(command)
alg.outputCommands.append(command)
36 changes: 36 additions & 0 deletions python/plugins/processing/algs/grass7/ext/r_mask_rast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
r_mask_rast.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 r_mask


def processCommand(alg):
r_mask.processCommand(alg)


def processOutputs(alg):
r_mask.processOutputs(alg)
36 changes: 36 additions & 0 deletions python/plugins/processing/algs/grass7/ext/r_mask_vect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
r_mask_vect.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 r_mask


def processCommand(alg):
r_mask.processCommand(alg)


def processOutputs(alg):
r_mask.processOutputs(alg)

0 comments on commit 6d39ad9

Please sign in to comment.