Skip to content
Browse files
Add (combined with r.timestamp) algorithm
  • Loading branch information
Médéric RIBREUX committed Feb 28, 2016
1 parent 9198c16 commit d5b5c6cd73405fe5caf293725816f8209d56ced4
@@ -0,0 +1,14 @@
Allows creation and/or modification of raster map layer support files (metadata).
Raster (r.*)
ParameterRaster|map|Name of raster map|False
ParameterString|title|Title for resultant raster map|None|False|True
ParameterString|timestamp|r.timestamp date: Datetime, datetime1/datetime2, or 'none' to remove'|None|False|True
ParameterString|history|Text to append to the next line of the map's metadata file|None|True|True
ParameterString|units|Text to use for map data units|None|False|True
ParameterString|vdatum|Text to use for map vertical datum|None|False|True
ParameterString|source1|Text to use for data source, line 1|None|False|True
ParameterString|source2|Text to use for data source, line 2|None|False|True
ParameterString|description|Text to use for data description or keyword(s)|None|False|True
*ParameterFile|loadhistory|Text file from which to load history|False
@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-

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 os

def processCommand(alg):
# We temporary remove the output
out = alg.getOutputFromName('output')
mapParam = alg.getParameterValue('map')
alg.exportedLayers[out.value] = alg.exportedLayers[mapParam]
timestamp = alg.getParameterValue('timestamp')
if timestamp:
command = "r.timestamp map={} date='{}'".format(alg.exportedLayers[mapParam],

# We re-add the new output

def processOutputs(alg):
'creator': 'TIFFTAG_ARTIST', 'timestamp': 'TIFFTAG_DATETIME',
'source2': 'GRASS_SOURCE2', 'comments': 'GRASS_HISTORY', 'vdatum': 'GRASS_VDATUM'}
awk = "awk -F '=' '"
for support, tag in tags.items():
awk = '{0} /{1}=".+"/{{ print \"{2}=\"substr($0,{3},length($0) - {3})"," }}'.format(
awk, support, tag, len(support) + 3)

# Output results ('from' table and output table)
out = alg.getOutputValue('output')
command = u"SDF=$( -e map={} | {}')".format(alg.exportedLayers[out], awk)
command = u"r.out.gdal --overwrite -c createopt=\"TFW=YES,COMPRESS=LZW\" input={} output=\"{}\" metaopt=\"${{SDF%%,}}\"".format(
alg.exportedLayers[out], out)

0 comments on commit d5b5c6c

Please sign in to comment.