|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +""" |
| 4 | +*************************************************************************** |
| 5 | + r_tile.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 for command |
| 31 | + output_dir = alg.getOutputFromName('output_dir') |
| 32 | + alg.removeOutputFromName('output_dir') |
| 33 | + alg.processCommand() |
| 34 | + alg.addOutput(output_dir) |
| 35 | + |
| 36 | + |
| 37 | +def processOutputs(alg): |
| 38 | + # All the named rasters should be extracted to output_dir |
| 39 | + basename = alg.getParameterValue('output') |
| 40 | + output_dir = alg.getOutputValue('output_dir') |
| 41 | + |
| 42 | + # Get the list of rasters matching the basename |
| 43 | + commands = ["for r in $(g.list type=rast pattern='{}*'); do".format(basename)] |
| 44 | + commands.append(" r.out.gdal -t input=${{r}} output={}/${{r}}.tif createopt=\"TFW=YES,COMPRESS=LZW\"".format(output_dir)) |
| 45 | + commands.append("done") |
| 46 | + alg.commands.extend(commands) |
0 commit comments