Skip to content

Commit

Permalink
r.reclass inline rules also for MS-Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Médéric Ribreux committed Feb 12, 2016
1 parent 43b39ef commit b780d7c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions python/plugins/processing/algs/grass7/ext/r_reclass.py
Expand Up @@ -38,13 +38,20 @@ def processCommand(alg):
""" Handle inline rules """
txtRules = alg.getParameterValue(u'txtrules')
if txtRules:
# Creates a temporary txt file
tempRulesName = alg.getTempFilename()

# Inject rules into temporary txt file
with open(tempRulesName, "w") as tempRules:
tempRules.write(txtRules)

raster = alg.getParameterValue(u'input')
output = alg.getOutputFromName(u'output')
alg.exportedLayers[output.value] = output.name + alg.uniqueSufix
if raster:
raster = alg.exportedLayers[raster]
command = u"echo \"{}\" | r.reclass input={} rules=- output={} --overwrite".format(
txtRules, raster, output.name + alg.uniqueSufix)
command = u"r.reclass input={} rules=- output={} --overwrite < {}".format(
raster, output.name + alg.uniqueSufix, tempRulesName)
alg.commands.append(command)
else:
alg.processCommand()

0 comments on commit b780d7c

Please sign in to comment.