[GRASS-SVN] r72992 - grass-addons/grass7/imagery/i.sentinel.mask

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 16 05:57:49 PDT 2018


Author: Robifag
Date: 2018-07-16 05:57:48 -0700 (Mon, 16 Jul 2018)
New Revision: 72992

Modified:
   grass-addons/grass7/imagery/i.sentinel.mask/i.sentinel.mask.html
   grass-addons/grass7/imagery/i.sentinel.mask/i.sentinel.mask.py
Log:
Small changes to the manual page and to the python script in order to make it compatible with the output of i.sentinel.preproc (new module soon available)

Modified: grass-addons/grass7/imagery/i.sentinel.mask/i.sentinel.mask.html
===================================================================
--- grass-addons/grass7/imagery/i.sentinel.mask/i.sentinel.mask.html	2018-07-15 18:38:37 UTC (rev 72991)
+++ grass-addons/grass7/imagery/i.sentinel.mask/i.sentinel.mask.html	2018-07-16 12:57:48 UTC (rev 72992)
@@ -17,7 +17,7 @@
 
 <p>
 The algorithm has been developed starting from rules found in literature (Parmes et. al 2017) and conveniently refined.<br>
-Regarding the detection of shadows, some misclassification can occur. Often shadows and water have in fact similar reflectance 
+Regarding the detection of shadows, the algorithm has been developed to identify only the shadows of clouds on the ground but some misclassification can occur. Often shadows and water have in fact similar reflectance 
 values which can lead to erroneous classification of water bodies as shadows. Therefore, in order to increase the accuracy of 
 the final shadow mask, a control check is implemented. Clouds and shadows are spatially intersected in order to remove misclassified areas. 
 This means that all those shadow geometries which do not intersect a cloud geometry are removed.
@@ -35,6 +35,9 @@
 </center-->
 
 <p>
+The algorithm works on reflectance values (Bottom of Atmosphere Reflectance) therefore the atmospheric correction has to be applied to all input bands (see <a href="i.atcorr.html">i.atcorr</a>)
+
+<p>
 All necessary input bands (blue, green, red, nir, nir8a, swir11, swir12) must be imported in GRASS and specified one by one or using a text file.
 The text file has to be written following the syntax below: <em>variable=your_map</em>
 

Modified: grass-addons/grass7/imagery/i.sentinel.mask/i.sentinel.mask.py
===================================================================
--- grass-addons/grass7/imagery/i.sentinel.mask/i.sentinel.mask.py	2018-07-15 18:38:37 UTC (rev 72991)
+++ grass-addons/grass7/imagery/i.sentinel.mask/i.sentinel.mask.py	2018-07-16 12:57:48 UTC (rev 72992)
@@ -112,6 +112,22 @@
 #% guisection: Output
 #%end
 #%option
+#% key: cloud_threshold
+#% type: integer
+#% description: threshold for cleaning small areas from cloud mask
+#% required : yes
+#% answer: 50000
+#% guisection: Output
+#%end
+#%option
+#% key: shadow_threshold
+#% type: integer
+#% description: threshold for cleaning small areas from shadow mask
+#% required : yes
+#% answer: 10000
+#% guisection: Output
+#%end
+#%option
 #% key: mtd_file
 #% type: string
 #% gisprompt: old,file,file
@@ -218,8 +234,8 @@
     d = 'double'
     f_bands = {}
     scale_fac = options['scale_fac']
-    cloud_clean_T = 50000
-    shadow_clean_T = 10000
+    cloud_threshold = options['cloud_threshold']
+    shadow_threshold = options['shadow_threshold']
     raster_max = {}
     cloud_mask = options['cloud_mask']
     shadow_mask = options['shadow_mask']
@@ -263,8 +279,8 @@
     else:
         gscript.warning(_('Any rescale factor has been applied'))
         for key, b in bands.items():
-            if gscript.raster_info(b)['datatype'] != "DCELL":
-                gscript.fatal("Raster maps must be double")
+            if gscript.raster_info(b)['datatype'] != "DCELL" and gscript.raster_info(b)['datatype'] != "FCELL":
+                gscript.fatal("Raster maps must be DCELL o FCELL")
             else:
                 f_bands = bands
 
@@ -309,7 +325,7 @@
         third_rule,
         fourth_rule,
         fifth_rule)
-    expr_c = '{} = if({}, 0, null( ))'.format(
+    expr_c = '{} = if({}, 0, null())'.format(
         tmp["cloud_def"],
         cloud_rules)
     gscript.mapcalc(expr_c, overwrite=True)
@@ -324,7 +340,7 @@
         input=tmp["cloud_v"],
         output=cloud_mask,
         tool='rmarea',
-        threshold=cloud_clean_T)
+        threshold=cloud_threshold)
     gscript.message(_('--- Finish cloud detection procedure ---'))
     ### end of Clouds detection ####
 
@@ -353,7 +369,7 @@
         shadow_rules = '(({} == 1) && ({} < 0.007))'.format(
             sixth_rule, 
             seventh_rule)
-        expr_s = '{} = if({}, 0, null( ))'.format(
+        expr_s = '{} = if({}, 0, null())'.format(
             tmp["shadow_temp"],
             shadow_rules)
         gscript.mapcalc( expr_s, overwrite=True)
@@ -369,7 +385,7 @@
             input=tmp["shadow_temp_v"],
             output=tmp["shadow_temp_mask"],
             tool='rmarea',
-            threshold=shadow_clean_T)
+            threshold=shadow_threshold)
         gscript.message(_('--- Finish Shadows detection procedure ---'))
         ### end of shadows detection ###
 



More information about the grass-commit mailing list