소스 검색

t.rast.neighbors: transfer semantic label (#2218)

* t.rast.neighbors: add option to transfer semantic labels, update manual
Markus Metz 3 년 전
부모
커밋
79ff42d65a
2개의 변경된 파일27개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      temporal/t.rast.neighbors/t.rast.neighbors.html
  2. 22 0
      temporal/t.rast.neighbors/t.rast.neighbors.py

+ 5 - 0
temporal/t.rast.neighbors/t.rast.neighbors.html

@@ -15,6 +15,11 @@ The user can select a subset of the input space time raster dataset for
 processing using a SQL WHERE statement. The number of CPU's to be used
 for parallel processing can be specified with the <em>nprocs</em>
 option to speedup the computation on multi-core system.
+<p>
+Semantic labels are needed to relate output raster maps to input raster
+maps. E.g. with <em>method=stddev</em>, the user needs to know the
+spatial extent, the time stamp and the semantic label to determine
+which stddev map corresponds to which input map.
 
 <h2>EXAMPLE</h2>
 

+ 22 - 0
temporal/t.rast.neighbors/t.rast.neighbors.py

@@ -77,6 +77,17 @@
 # %end
 
 # %option
+# % key: semantic_labels
+# % type: string
+# % options: input,method
+# % description: Set semantic labels
+# % descriptions: input;copy semantic labels from input to output;method;append method name to input label if existing, otherwise use method name
+# % answer: input
+# % required: no
+# % multiple: no
+# %end
+
+# %option
 # % key: nprocs
 # % type: integer
 # % description: Number of r.neighbor processes to run in parallel
@@ -120,6 +131,7 @@ def main():
     method = options["method"]
     nprocs = options["nprocs"]
     time_suffix = options["suffix"]
+    new_labels = options["semantic_labels"]
 
     # Make sure the temporal database exists
     tgis.init()
@@ -187,6 +199,16 @@ def main():
             overwrite=overwrite,
             dbif=dbif,
         )
+        semantic_label = map.metadata.get_semantic_label()
+        if new_labels == "input":
+            if semantic_label is not None:
+                new_map.set_semantic_label(semantic_label)
+        elif new_labels == "method":
+            if semantic_label is not None:
+                semantic_label = f"{semantic_label}_{method}"
+            else:
+                semantic_label = method
+            new_map.set_semantic_label(semantic_label)
         new_maps.append(new_map)
 
         mod = copy.deepcopy(neighbor_module)