[GRASS-SVN] r70310 - in grass-addons/grass7/imagery: . i.in.probav

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 9 01:42:35 PST 2017


Author: stjo
Date: 2017-01-09 01:42:35 -0800 (Mon, 09 Jan 2017)
New Revision: 70310

Added:
   grass-addons/grass7/imagery/i.in.probav/
   grass-addons/grass7/imagery/i.in.probav/Makefile
   grass-addons/grass7/imagery/i.in.probav/i.in.probav.html
   grass-addons/grass7/imagery/i.in.probav/i.in.probav.py
Modified:
   grass-addons/grass7/imagery/Makefile
Log:
i.in.probav addon: script to import PROBA-V NDVI

Modified: grass-addons/grass7/imagery/Makefile
===================================================================
--- grass-addons/grass7/imagery/Makefile	2017-01-08 18:23:48 UTC (rev 70309)
+++ grass-addons/grass7/imagery/Makefile	2017-01-09 09:42:35 UTC (rev 70310)
@@ -17,6 +17,7 @@
 	i.gcp \
 	i.gravity \
 	i.histo.match \
+	i.in.probav \
 	i.lmf \
 	i.points.auto \
 	i.rotate \

Added: grass-addons/grass7/imagery/i.in.probav/Makefile
===================================================================
--- grass-addons/grass7/imagery/i.in.probav/Makefile	                        (rev 0)
+++ grass-addons/grass7/imagery/i.in.probav/Makefile	2017-01-09 09:42:35 UTC (rev 70310)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = i.in.probav
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script


Property changes on: grass-addons/grass7/imagery/i.in.probav/Makefile
___________________________________________________________________
Added: svn:mime-type
   + text/x-makefile
Added: svn:eol-style
   + native

Added: grass-addons/grass7/imagery/i.in.probav/i.in.probav.html
===================================================================
--- grass-addons/grass7/imagery/i.in.probav/i.in.probav.html	                        (rev 0)
+++ grass-addons/grass7/imagery/i.in.probav/i.in.probav.html	2017-01-09 09:42:35 UTC (rev 70310)
@@ -0,0 +1,53 @@
+<h2>DESCRIPTION</h2>
+
+<em>i.in.probav</em> imports Proba-V NDVI data sets.
+After the import the digital numbers (DN) are remapped to VEGETATION NDVI
+values and the NDVI color table is applied. The imported DN map is
+removed after remapping. It is also possible to change the scale and offset
+factor (default is scale: 0.004, offset: -0.08 for Proba-V)
+and to improve the memory usage (default is 300 MB).
+<p>
+Important for the Proba-V Data sets, is a user registration at
+<a href="http://www.vito-eodata.be/PDF/portal/Application.html#Home">the VITO portal</a> 
+necessary (Register Button in the Upper Right Corner).
+
+<h2>NOTES</h2>
+
+The Proba-V files are delivered in NetCDF (Network Common Data Form)
+format. It is required to have the GDAL libraries installed with NetCDF support.
+Also to check the necessary scale and offset factor with <b>gdalinfo</b>.
+
+<h3>Before Import</h3>
+
+When working with Proba-V NDVI, it it necessary to fix the range of the map because
+it exceeds the -180°..+180° range with entire world extent.
+You can shift the map slightly into the right position using
+<a href="http://www.gdal.org/gdal_translate.html">gdal_translate</a>.
+This example in <a href="https://grasswiki.osgeo.org/wiki/Global_datasets#ESA_Globcover_dataset">Global datasets</a> may help you.
+
+<h2>EXAMPLE</h2>
+<div class="code"><pre>
+# import of 300m NDVI
+i.in.probav input=c_gls_NDVI300_201611010000_GLOBE_PROBAV_V1.0.1.nc \
+            output=c_gls_NDVI300_201611010000_GLOBE_PROBAV_V1.0.1 memory=500
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<em>
+<a href="i.in.spotvgt.html">i.in.spotvgt</a>,
+<a href="r.in.gdal.html">r.in.gdal</a>
+</em>
+
+<h2>REFERENCES</h2>
+<ul>
+<li> <a href="http://www.vito-eodata.be/PDF/portal/Application.html#Home">VITO Product Distribution Portal</a></li>
+<li> <a href="http://www.vito-eodata.be/PDF/image/faq_help/Faq.html">PROBA-V FAQ</a></li>
+<li> <a href="http://www.vito-eodata.be/PDF/image/faq_help/Help.html#COLLECTION">VITO Collections help</a></li>
+</ul>
+
+<h2>AUTHOR</h2>
+
+Jonas Strobel<br>
+
+<p><i>Last changed: $Date$</i>


Property changes on: grass-addons/grass7/imagery/i.in.probav/i.in.probav.html
___________________________________________________________________
Added: svn:mime-type
   + text/html
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/imagery/i.in.probav/i.in.probav.py
===================================================================
--- grass-addons/grass7/imagery/i.in.probav/i.in.probav.py	                        (rev 0)
+++ grass-addons/grass7/imagery/i.in.probav/i.in.probav.py	2017-01-09 09:42:35 UTC (rev 70310)
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE:       i.in.probav
+# AUTHOR(S):    Jonas Strobel, intern at mundialis and terrestris, Bonn
+# PURPOSE:      i.in.probav
+# COPYRIGHT:    (C) 2017 by stjo, and the GRASS Development Team
+#
+#  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.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+############################################################################
+
+#%module
+#% description: Imports PROBA-V NDVI data in netCDF format into a raster map with real NDVI data range.
+#% keyword: imagery
+#% keyword: import
+#% keyword: NDVI
+#% keyword: PROBA-V
+#%end
+#%option G_OPT_F_INPUT
+#% description: Name of input PROBA-V NDVI .nc file
+#%end
+#%option G_OPT_R_OUTPUT
+#%end
+#%option
+#% key: scale
+#% type: double
+#% required: no
+#% multiple: no
+#% answer: 0.004
+#% key_desc: float
+#% description: Scale factor for input
+#%end
+#%option
+#% key: shift
+#% type: double
+#% required: no
+#% multiple: no
+#% answer: -0.08
+#% key_desc: float
+#% label: Shift factor for input
+#% description: Offset factor for input
+#%end
+#%option
+#% key: memory
+#% type: double
+#% required: no
+#% multiple: no
+#% options: 0-2047
+#% answer: 300
+#% key_desc: integer
+#% description: Maximum memory to be used in MB
+#%end
+
+import sys
+import os
+import atexit
+import grass.script as gscript
+from grass.exceptions import CalledModuleError
+
+def cleanup():
+    pass
+
+
+def main():
+
+    global tmpfile
+    infile = options['input']
+    out = options['output']
+    scale = options['scale']
+    offset = options['shift']
+    mem = options['memory']
+
+
+    pid = os.getpid()
+    tmpname = str(pid) + 'i.in.probav'
+    tmpfile = gscript.tempfile()
+
+    if not gscript.overwrite() and gscript.find_file(out)['file']:
+        gscript.fatal(("<%s> already exists. Aborting.") % out)
+
+    # Are we in LatLong location?
+    s = gscript.read_command("g.proj", flags='j')
+    kv = gscript.parse_key_val(s)
+    if kv['+proj'] != 'longlat':
+        gscript.fatal(("This module only operates in LatLong locations"))
+
+
+    try:
+        gscript.message('Importing raster map <' + out + '>...')
+        gscript.run_command('r.in.gdal', input=infile, output=tmpname, memory=mem, quiet=True)
+    except CalledModuleError:
+        gscript.fatal(("An error occurred. Stop."))
+
+    # What is the relation between the digital number and the real NDVI ?
+    # Real NDVI =coefficient a * Digital Number + coefficient b
+    #           = a * DN +b
+    #
+    # Coefficient a = scale
+    # Coefficient b = offset
+
+    # create temporary region
+    gscript.use_temp_region()
+    gscript.run_command('g.region', raster=tmpname, quiet=True)
+    gscript.message("Remapping digital numbers to NDVI...")
+
+    # do the mapcalc
+    gscript.mapcalc("${out} = ${a} * ${tmpname} + ${b}", out=out, a=scale, tmpname=tmpname, b=offset)
+
+    # remove original input
+    gscript.run_command('g.remove', type='raster', name=tmpname, quiet=True, flags='f')
+    
+    # set color table to ndvi
+    gscript.run_command('r.colors', map=out, color='ndvi')
+
+    gscript.message(("Done: generated map <%s>") % out)
+
+    return 0
+
+if __name__ == "__main__":
+    options, flags = gscript.parser()
+    atexit.register(cleanup)
+    main()


Property changes on: grass-addons/grass7/imagery/i.in.probav/i.in.probav.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list