[GRASS-SVN] r71818 - in grass-addons/grass7/raster: . r.clip

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 23 20:18:25 PST 2017


Author: wenzeslaus
Date: 2017-11-23 20:18:25 -0800 (Thu, 23 Nov 2017)
New Revision: 71818

Added:
   grass-addons/grass7/raster/r.clip/
   grass-addons/grass7/raster/r.clip/Makefile
   grass-addons/grass7/raster/r.clip/r.clip.html
   grass-addons/grass7/raster/r.clip/r.clip.py
Modified:
   grass-addons/grass7/raster/Makefile
Log:
r.clip: simple module to to crop rasters to region

Modified: grass-addons/grass7/raster/Makefile
===================================================================
--- grass-addons/grass7/raster/Makefile	2017-11-24 02:53:51 UTC (rev 71817)
+++ grass-addons/grass7/raster/Makefile	2017-11-24 04:18:25 UTC (rev 71818)
@@ -17,6 +17,7 @@
 	r.agent \
 	r.area \
 	r.basin \
+	r.clip \
 	r.vect.stats \
 	r.bioclim \
 	r.bitpattern \

Added: grass-addons/grass7/raster/r.clip/Makefile
===================================================================
--- grass-addons/grass7/raster/r.clip/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.clip/Makefile	2017-11-24 04:18:25 UTC (rev 71818)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.clip
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script


Property changes on: grass-addons/grass7/raster/r.clip/Makefile
___________________________________________________________________
Added: svn:mime-type
   + text/x-makefile
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.clip/r.clip.html
===================================================================
--- grass-addons/grass7/raster/r.clip/r.clip.html	                        (rev 0)
+++ grass-addons/grass7/raster/r.clip/r.clip.html	2017-11-24 04:18:25 UTC (rev 71818)
@@ -0,0 +1,42 @@
+<h2>DESCRIPTION</h2>
+
+The module extracts portion of the input raster map according to the
+current computational region. The areas outside of the computational
+region are clipped and only the inner part is kept.
+
+<p>
+By default the cell size and the cell alignment of the original raster
+is preserved. In other words, the output map inherits its resolution and
+cell positions (grid) from the input raster rather than the
+computational region.
+
+<p>
+If resampling into the cells size and cell alignment of the
+current computational is desired, the module can perform a nearest
+neighbor resampling when the <b>-r</b> flag is used.
+If more advanced resampling is required, the user is advised to to use
+one of the dedicated resampling modules.
+
+<p>
+If mask (<em><a href="r.mask.html">r.mask</a></em>) is active, it is
+respected and the output raster map will contain NULL (no data) values
+according to the mask.
+
+<p>
+The color table of the output raster map is set according to the
+input raster map, so that the colors in both raster maps will match.
+
+<h2>SEE ALSO</h2>
+
+<a href="g.region.html">g.region</a>,
+<a href="r.mask.html">r.mask</a>,
+<a href="r.patch.html">r.patch</a>,
+<a href="r.mapcalc.html">r.mapcalc</a>,
+<a href="r.resample.html">r.resample</a>,
+<a href="r.resamp.rst.html">r.resamp.rst</a>
+
+<h2>AUTHOR</h2>
+
+Vaclav Petras, <a href="http://geospatial.ncsu.edu/osgeorel/">NCSU GeoForAll Lab</a>
+
+<p><i>Last changed: $Date$</i>


Property changes on: grass-addons/grass7/raster/r.clip/r.clip.html
___________________________________________________________________
Added: svn:mime-type
   + text/html
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.clip/r.clip.py
===================================================================
--- grass-addons/grass7/raster/r.clip/r.clip.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.clip/r.clip.py	2017-11-24 04:18:25 UTC (rev 71818)
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+#%module
+#% label: Extracts portion of the input map which overlaps with current region
+#% description: Extracts portion of the input raster map which is in the current computational region
+#% keyword: raster
+#% keyword: extract
+#% keyword: clip
+#% keyword: crop
+#% keyword: trim
+#% keyword: extent
+#%end
+#%option G_OPT_R_INPUT
+#%end
+#%option G_OPT_R_OUTPUT
+#%end
+#%flag
+#% key: r
+#% label: Resample input raster according to the computational region
+#% description: By default cell size and alignment of the original raster is preserved
+#%end
+
+
+import sys
+import atexit
+
+import grass.script as gs
+
+
+def main():
+    options, flags = gs.parser()
+
+    original = options['input']
+    clipped = options['output']
+
+    # set region res and grid to match raster to avoid resampling
+    if not flags['r']:
+        info = gs.raster_info(original)
+        gs.use_temp_region()
+        atexit.register(gs.del_temp_region)
+        gs.run_command('g.region', align=original,
+                       ewres=info['ewres'], nsres=info['nsres'])
+
+    gs.mapcalc("$clipped = $original", clipped=clipped, original=original)
+
+if __name__ == '__main__':
+    sys.exit(main())


Property changes on: grass-addons/grass7/raster/r.clip/r.clip.py
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list