Skip to content
Permalink
Browse files

Add r.mask algorithm

  • Loading branch information
Médéric RIBREUX
Médéric RIBREUX committed Feb 28, 2016
1 parent d5b5c6c commit ede5f8f09738cbb492c06faac115ed3fb40fdee6
@@ -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
@@ -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
@@ -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)
@@ -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)
@@ -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 ede5f8f

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