diff --git a/apple-touch-icon-120x120.png b/apple-touch-icon-120x120.png index f8f6855d8..e6782e64d 100644 Binary files a/apple-touch-icon-120x120.png and b/apple-touch-icon-120x120.png differ diff --git a/apple-touch-icon-152x152.png b/apple-touch-icon-152x152.png index 74b074a53..1216a2c21 100644 Binary files a/apple-touch-icon-152x152.png and b/apple-touch-icon-152x152.png differ diff --git a/apple-touch-icon-180x180.png b/apple-touch-icon-180x180.png index 94d22e1f5..4418f248b 100644 Binary files a/apple-touch-icon-180x180.png and b/apple-touch-icon-180x180.png differ diff --git a/apple-touch-icon-60x60.png b/apple-touch-icon-60x60.png index 6234f9190..58c8b745c 100644 Binary files a/apple-touch-icon-60x60.png and b/apple-touch-icon-60x60.png differ diff --git a/apple-touch-icon-76x76.png b/apple-touch-icon-76x76.png index f99773a05..7ba439838 100644 Binary files a/apple-touch-icon-76x76.png and b/apple-touch-icon-76x76.png differ diff --git a/apple-touch-icon.png b/apple-touch-icon.png index 94d22e1f5..9167b640a 100644 Binary files a/apple-touch-icon.png and b/apple-touch-icon.png differ diff --git a/favicon-16x16.png b/favicon-16x16.png index ba48aa041..75094b579 100644 Binary files a/favicon-16x16.png and b/favicon-16x16.png differ diff --git a/favicon-32x32.png b/favicon-32x32.png index a602979f8..8513c4c60 100644 Binary files a/favicon-32x32.png and b/favicon-32x32.png differ diff --git a/pkgdown.yml b/pkgdown.yml index 4cb28ff46..2c5ed84b5 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 3.1.11 pkgdown: 2.0.9 pkgdown_sha: ~ articles: {} -last_built: 2024-05-25T11:26Z +last_built: 2024-05-29T10:41Z urls: reference: https://rspatial.github.io/terra/reference article: https://rspatial.github.io/terra/articles diff --git a/reference/NIPD2-1.png b/reference/NIPD2-1.png new file mode 100644 index 000000000..c585fa198 Binary files /dev/null and b/reference/NIPD2-1.png differ diff --git a/reference/NIPD2-2.png b/reference/NIPD2-2.png new file mode 100644 index 000000000..f1bbc68c6 Binary files /dev/null and b/reference/NIPD2-2.png differ diff --git a/reference/NIPD2-3.png b/reference/NIPD2-3.png new file mode 100644 index 000000000..7bff445b5 Binary files /dev/null and b/reference/NIPD2-3.png differ diff --git a/reference/NIPD2-4.png b/reference/NIPD2-4.png new file mode 100644 index 000000000..40bc6ae79 Binary files /dev/null and b/reference/NIPD2-4.png differ diff --git a/reference/NIPD2-5.png b/reference/NIPD2-5.png new file mode 100644 index 000000000..689b01638 Binary files /dev/null and b/reference/NIPD2-5.png differ diff --git a/reference/NIPD2-6.png b/reference/NIPD2-6.png new file mode 100644 index 000000000..cc7a61b42 Binary files /dev/null and b/reference/NIPD2-6.png differ diff --git a/reference/NIPD2.html b/reference/NIPD2.html new file mode 100644 index 000000000..8befad3b1 --- /dev/null +++ b/reference/NIPD2.html @@ -0,0 +1,239 @@ + +Number of immediate adjacent cells flowing into each cell (Watershed Analysis) — NIDP2 • terra + Skip to contents + + +
+
+
+ +
+

It computes the number of immediate adjacent cells flowing into each cell (Watershed Analysis)

+
+ +
+

Usage

+
# S4 method for SpatRaster
+NIDP2(p,filename="",...)
+
+ +
+

Arguments

+
p
+

Flow Direction raster map, a SpatRaster-class object, see also terrain.

+ +
filename,...
+

list. Options for writing files as in writeRaster

+ +
+
+

Value

+ + + +

A SpatRaster-class (raster) map containing the value for each cell.

+
+
+

Details

+

NDIP is computed to preliminarly to compute Flow Accumulation area in the algorithm proposed by Zhouo at al,2019.

+ + +
+
+

See also

+ +
+
+

Author

+ + +

Emanuele Cordano (implementation of the algorithm within the package),Guiyun Zhou, Wenyan Dong and Hongqiang Wei

+
+
+

References

+

Zhou, G., Wei, H. & Fu, S. A fast and simple algorithm for calculating flow accumulation matrices from raster digital elevation. Front. Earth Sci. 13, 317–326 (2019). https://doi.org/10.1007/s11707-018-0725-9 +https://link.springer.com/article/10.1007/s11707-018-0725-9

+
+ +
+

Examples

+

+
+elev1 <- array(NA,c(9,9))
+elev2 <- elev1
+dx <- 1
+dy <- 1 
+for (r in 1:nrow(elev1)) {
+  y <- (r-5)*dx
+  for (c in 1:ncol(elev1)) {
+    
+    x <- (c-5)*dy
+    elev1[r,c] <- 5*(x^2+y^2)
+    elev2[r,c] <- 10+5*(abs(x))-0.001*y ### 5*(x^2+y^2)
+  }
+} 
+
+
+## Elevation Raster Maps
+elev1 <- rast(elev1)
+elev2 <- rast(elev2)
+
+t(array(elev1[],rev(dim(elev1)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]  160  125  100   85   80   85  100  125  160
+#>  [2,]  125   90   65   50   45   50   65   90  125
+#>  [3,]  100   65   40   25   20   25   40   65  100
+#>  [4,]   85   50   25   10    5   10   25   50   85
+#>  [5,]   80   45   20    5    0    5   20   45   80
+#>  [6,]   85   50   25   10    5   10   25   50   85
+#>  [7,]  100   65   40   25   20   25   40   65  100
+#>  [8,]  125   90   65   50   45   50   65   90  125
+#>  [9,]  160  125  100   85   80   85  100  125  160
+t(array(elev2[],rev(dim(elev2)[1:2])))
+#>         [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]
+#>  [1,] 30.004 25.004 20.004 15.004 10.004 15.004 20.004 25.004 30.004
+#>  [2,] 30.003 25.003 20.003 15.003 10.003 15.003 20.003 25.003 30.003
+#>  [3,] 30.002 25.002 20.002 15.002 10.002 15.002 20.002 25.002 30.002
+#>  [4,] 30.001 25.001 20.001 15.001 10.001 15.001 20.001 25.001 30.001
+#>  [5,] 30.000 25.000 20.000 15.000 10.000 15.000 20.000 25.000 30.000
+#>  [6,] 29.999 24.999 19.999 14.999  9.999 14.999 19.999 24.999 29.999
+#>  [7,] 29.998 24.998 19.998 14.998  9.998 14.998 19.998 24.998 29.998
+#>  [8,] 29.997 24.997 19.997 14.997  9.997 14.997 19.997 24.997 29.997
+#>  [9,] 29.996 24.996 19.996 14.996  9.996 14.996 19.996 24.996 29.996
+
+plot(elev1)
+
+plot(elev2)
+
+
+## Flow Direction Raster Maps
+flowdir1<- terrain(elev1,v="flowdir")
+flowdir2<- terrain(elev2,v="flowdir")
+
+
+t(array(flowdir1[],rev(dim(flowdir1)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    2    2    2    4    4    4    8    8    8
+#>  [2,]    2    2    2    4    4    4    8    8    8
+#>  [3,]    2    2    2    4    4    4    8    8    8
+#>  [4,]    1    1    1    2    4    8   16   16   16
+#>  [5,]    1    1    1    1    0   16   16   16   16
+#>  [6,]    1    1    1  128   64   32   16   16   16
+#>  [7,]  128  128  128   64   64   64   32   32   32
+#>  [8,]  128  128  128   64   64   64   32   32   32
+#>  [9,]  128  128  128   64   64   64   32   32   32
+t(array(flowdir2[],rev(dim(flowdir2)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    1    1    1    1    4   16   16   16   16
+#>  [2,]    1    1    1    1    4   16   16   16   16
+#>  [3,]    1    1    1    1    4   16   16   16   16
+#>  [4,]    1    1    1    1    4   16   16   16   16
+#>  [5,]    1    1    1    1    4   16   16   16   16
+#>  [6,]    1    1    1    1    4   16   16   16   16
+#>  [7,]    1    1    1    1    4   16   16   16   16
+#>  [8,]    1    1    1    1    4   16   16   16   16
+#>  [9,]    1    1    1    1    0   16   16   16   16
+
+plot(flowdir1)
+
+plot(flowdir2)
+
+
+## 
+nidp1 <- NIDP2((flowdir1))
+nidp2 <- NIDP2((flowdir2))
+
+t(array(nidp1[],rev(dim(nidp1)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    0    0    0    0    0    0    0    0    0
+#>  [2,]    0    1    1    2    1    2    1    1    0
+#>  [3,]    0    1    1    2    1    2    1    1    0
+#>  [4,]    0    2    2    3    1    3    2    2    0
+#>  [5,]    0    1    1    1    9    1    1    1    0
+#>  [6,]    0    2    2    3    1    3    2    2    0
+#>  [7,]    0    1    1    2    1    2    1    1    0
+#>  [8,]    0    1    1    2    1    2    1    1    0
+#>  [9,]    0    0    0    0    0    0    0    0    0
+t(array(nidp2[],rev(dim(nidp2)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    0    1    1    1    2    1    1    1    0
+#>  [2,]    0    1    1    1    3    1    1    1    0
+#>  [3,]    0    1    1    1    3    1    1    1    0
+#>  [4,]    0    1    1    1    3    1    1    1    0
+#>  [5,]    0    1    1    1    3    1    1    1    0
+#>  [6,]    0    1    1    1    3    1    1    1    0
+#>  [7,]    0    1    1    1    3    1    1    1    0
+#>  [8,]    0    1    1    1    3    1    1    1    0
+#>  [9,]    0    1    1    1    4    1    1    1    0
+
+plot(nidp1)
+
+plot(nidp2)
+
+
+
+
+
+ + +
+ + + + + + + diff --git a/reference/flowAccu2-1.png b/reference/flowAccu2-1.png new file mode 100644 index 000000000..c585fa198 Binary files /dev/null and b/reference/flowAccu2-1.png differ diff --git a/reference/flowAccu2-2.png b/reference/flowAccu2-2.png new file mode 100644 index 000000000..f1bbc68c6 Binary files /dev/null and b/reference/flowAccu2-2.png differ diff --git a/reference/flowAccu2-3.png b/reference/flowAccu2-3.png new file mode 100644 index 000000000..7bff445b5 Binary files /dev/null and b/reference/flowAccu2-3.png differ diff --git a/reference/flowAccu2-4.png b/reference/flowAccu2-4.png new file mode 100644 index 000000000..40bc6ae79 Binary files /dev/null and b/reference/flowAccu2-4.png differ diff --git a/reference/flowAccu2-5.png b/reference/flowAccu2-5.png new file mode 100644 index 000000000..80eac65f8 Binary files /dev/null and b/reference/flowAccu2-5.png differ diff --git a/reference/flowAccu2-6.png b/reference/flowAccu2-6.png new file mode 100644 index 000000000..a0398dd0a Binary files /dev/null and b/reference/flowAccu2-6.png differ diff --git a/reference/flowAccu2.html b/reference/flowAccu2.html new file mode 100644 index 000000000..2101d5509 --- /dev/null +++ b/reference/flowAccu2.html @@ -0,0 +1,246 @@ + +Flow accumulation or Total contributing Area (Watershed Analysis) — flowAccu2 • terra + Skip to contents + + +
+
+
+ +
+

It computes Flow accumulation or Total contributing Area in terms of numbers of cells upstrem each cell(Watershed Analysis).

+
+ +
+

Usage

+
# S4 method for SpatRaster
+flowAccu2(p,filename="",...)
+
+ +
+

Arguments

+
p
+

Flow Direction raster map, a SpatRaster-class object, see also terrain.

+ +
filename,...
+

list. Options for writing files as in writeRaster

+ +
+
+

Value

+ + + +

A SpatRaster-class (raster) map containing the value for each cell.

+
+
+

Details

+

The algoritm is an adaptation of the one proposed by Zhou at al, 2019.

+ + +

ArGIS impletation (same result but different algorithm): https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-analyst/flow-accumulation.html

+
+ +
+

Author

+ + +

Emanuele Cordano (implementation of the algorithm within the package),Guiyun Zhou, Wenyan Dong, and Hongqiang Wei

+
+
+

References

+

Zhou, G., Wei, H. & Fu, S. A fast and simple algorithm for calculating flow accumulation matrices from raster digital elevation. Front. Earth Sci. 13, 317–326 (2019). https://doi.org/10.1007/s11707-018-0725-9 +https://link.springer.com/article/10.1007/s11707-018-0725-9 +Further references: https://ica-abs.copernicus.org/articles/1/434/2019/

+
+ +
+

Examples

+

+
+elev1 <- array(NA,c(9,9))
+elev2 <- elev1
+dx <- 1
+dy <- 1 
+for (r in 1:nrow(elev1)) {
+  y <- (r-5)*dx
+  for (c in 1:ncol(elev1)) {
+    
+    x <- (c-5)*dy
+    elev1[r,c] <- 5*(x^2+y^2)
+    elev2[r,c] <- 10+5*(abs(x))-0.001*y ### 5*(x^2+y^2)
+  }
+} 
+
+
+## Elevation Raster Maps
+elev1 <- rast(elev1)
+elev2 <- rast(elev2)
+
+t(array(elev1[],rev(dim(elev1)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]  160  125  100   85   80   85  100  125  160
+#>  [2,]  125   90   65   50   45   50   65   90  125
+#>  [3,]  100   65   40   25   20   25   40   65  100
+#>  [4,]   85   50   25   10    5   10   25   50   85
+#>  [5,]   80   45   20    5    0    5   20   45   80
+#>  [6,]   85   50   25   10    5   10   25   50   85
+#>  [7,]  100   65   40   25   20   25   40   65  100
+#>  [8,]  125   90   65   50   45   50   65   90  125
+#>  [9,]  160  125  100   85   80   85  100  125  160
+t(array(elev2[],rev(dim(elev2)[1:2])))
+#>         [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]
+#>  [1,] 30.004 25.004 20.004 15.004 10.004 15.004 20.004 25.004 30.004
+#>  [2,] 30.003 25.003 20.003 15.003 10.003 15.003 20.003 25.003 30.003
+#>  [3,] 30.002 25.002 20.002 15.002 10.002 15.002 20.002 25.002 30.002
+#>  [4,] 30.001 25.001 20.001 15.001 10.001 15.001 20.001 25.001 30.001
+#>  [5,] 30.000 25.000 20.000 15.000 10.000 15.000 20.000 25.000 30.000
+#>  [6,] 29.999 24.999 19.999 14.999  9.999 14.999 19.999 24.999 29.999
+#>  [7,] 29.998 24.998 19.998 14.998  9.998 14.998 19.998 24.998 29.998
+#>  [8,] 29.997 24.997 19.997 14.997  9.997 14.997 19.997 24.997 29.997
+#>  [9,] 29.996 24.996 19.996 14.996  9.996 14.996 19.996 24.996 29.996
+
+plot(elev1)
+
+plot(elev2)
+
+
+## Flow Direction Raster Maps
+flowdir1<- terrain(elev1,v="flowdir")
+flowdir2<- terrain(elev2,v="flowdir")
+u <- terrain(flowdir2,"flowacc")
+
+t(array(flowdir1[],rev(dim(flowdir1)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    2    2    2    4    4    4    8    8    8
+#>  [2,]    2    2    2    4    4    4    8    8    8
+#>  [3,]    2    2    2    4    4    4    8    8    8
+#>  [4,]    1    1    1    2    4    8   16   16   16
+#>  [5,]    1    1    1    1    0   16   16   16   16
+#>  [6,]    1    1    1  128   64   32   16   16   16
+#>  [7,]  128  128  128   64   64   64   32   32   32
+#>  [8,]  128  128  128   64   64   64   32   32   32
+#>  [9,]  128  128  128   64   64   64   32   32   32
+t(array(flowdir2[],rev(dim(flowdir2)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    1    1    1    1    4   16   16   16   16
+#>  [2,]    1    1    1    1    4   16   16   16   16
+#>  [3,]    1    1    1    1    4   16   16   16   16
+#>  [4,]    1    1    1    1    4   16   16   16   16
+#>  [5,]    1    1    1    1    4   16   16   16   16
+#>  [6,]    1    1    1    1    4   16   16   16   16
+#>  [7,]    1    1    1    1    4   16   16   16   16
+#>  [8,]    1    1    1    1    4   16   16   16   16
+#>  [9,]    1    1    1    1    0   16   16   16   16
+
+plot(flowdir1)
+
+plot(flowdir2)
+
+
+## 
+flow_acc1 <- flowAccu2((flowdir1))
+flow_acc2 <- flowAccu2((flowdir2))
+## Alternative option 
+## here the argument of "terrain"functions is not elevation but flow directions.
+
+flow_acc2a <- terrain(flowdir2,"flowacc") 
+t(array(flow_acc1[],rev(dim(flow_acc1)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    1    1    1    1    1    1    1    1    1
+#>  [2,]    1    2    2    3    2    3    2    2    1
+#>  [3,]    1    2    3    6    3    6    3    2    1
+#>  [4,]    1    3    6   16    4   16    6    3    1
+#>  [5,]    1    2    3    4   81    4    3    2    1
+#>  [6,]    1    3    6   16    4   16    6    3    1
+#>  [7,]    1    2    3    6    3    6    3    2    1
+#>  [8,]    1    2    2    3    2    3    2    2    1
+#>  [9,]    1    1    1    1    1    1    1    1    1
+t(array(flow_acc2[],rev(dim(flow_acc2)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    1    2    3    4    9    4    3    2    1
+#>  [2,]    1    2    3    4   18    4    3    2    1
+#>  [3,]    1    2    3    4   27    4    3    2    1
+#>  [4,]    1    2    3    4   36    4    3    2    1
+#>  [5,]    1    2    3    4   45    4    3    2    1
+#>  [6,]    1    2    3    4   54    4    3    2    1
+#>  [7,]    1    2    3    4   63    4    3    2    1
+#>  [8,]    1    2    3    4   72    4    3    2    1
+#>  [9,]    1    2    3    4   81    4    3    2    1
+
+plot(flow_acc1)
+
+plot(flow_acc2)
+
+
+
+
+
+
+
+ + +
+ + + + + + + diff --git a/reference/flowAccu2_weight-1.png b/reference/flowAccu2_weight-1.png new file mode 100644 index 000000000..c585fa198 Binary files /dev/null and b/reference/flowAccu2_weight-1.png differ diff --git a/reference/flowAccu2_weight-2.png b/reference/flowAccu2_weight-2.png new file mode 100644 index 000000000..f1bbc68c6 Binary files /dev/null and b/reference/flowAccu2_weight-2.png differ diff --git a/reference/flowAccu2_weight-3.png b/reference/flowAccu2_weight-3.png new file mode 100644 index 000000000..7bff445b5 Binary files /dev/null and b/reference/flowAccu2_weight-3.png differ diff --git a/reference/flowAccu2_weight-4.png b/reference/flowAccu2_weight-4.png new file mode 100644 index 000000000..40bc6ae79 Binary files /dev/null and b/reference/flowAccu2_weight-4.png differ diff --git a/reference/flowAccu2_weight-5.png b/reference/flowAccu2_weight-5.png new file mode 100644 index 000000000..80eac65f8 Binary files /dev/null and b/reference/flowAccu2_weight-5.png differ diff --git a/reference/flowAccu2_weight-6.png b/reference/flowAccu2_weight-6.png new file mode 100644 index 000000000..a0398dd0a Binary files /dev/null and b/reference/flowAccu2_weight-6.png differ diff --git a/reference/flowAccu2_weight-7.png b/reference/flowAccu2_weight-7.png new file mode 100644 index 000000000..03b49b44f Binary files /dev/null and b/reference/flowAccu2_weight-7.png differ diff --git a/reference/flowAccu2_weight-8.png b/reference/flowAccu2_weight-8.png new file mode 100644 index 000000000..60f452ca4 Binary files /dev/null and b/reference/flowAccu2_weight-8.png differ diff --git a/reference/flowAccu2_weight.html b/reference/flowAccu2_weight.html new file mode 100644 index 000000000..dd9ba79fe --- /dev/null +++ b/reference/flowAccu2_weight.html @@ -0,0 +1,300 @@ + +Flow accumulation or Total contributing Area (Watershed Analysis) — flowAccu2_weight • terra + Skip to contents + + +
+
+
+ +
+

It computes Flow accumulation or Total contributing Area (Watershed Analysis) or a cumulation value in function of a weight value asspciated to each cell.

+
+ +
+

Usage

+
# S4 method for SpatRaster,SpatRaster
+flowAccu2_weight(p,weight,filename="",...)
+
+ +
+

Arguments

+
p
+

Flow Direction raster map, a SpatRaster-class object, see also terrain.

+ +
weight
+

Weight/Score raster map, a SpatRaster-class object, e.g call area map or Averaged Precipitation Map.

+ +
filename,...
+

list. Options for writing files as in writeRaster

+ +
+
+

Value

+ + + +

A SpatRaster-class (raster) map containing the value for each cell.

+
+
+

Details

+

The algoritm is an adaptation of the one proposed by Zhou et al, 2019

+ +

Respect to the one of flowAccu2, this function takes into account that each cell can contain a value/weight/score, see weight argument, e.g. the planar area of each cell (in square kilometres) or a precipitation runoff value, in this case the flow accumulations is the total contributing area or the total contributing runoff W. In flowAccu2 ,instead, each cell contains a value equal to 1 and the flow accumulation corresponds only to the number of upslope cells.

+

Further ArGIS implementation of this index: https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-analyst/flow-accumulation.html

+
+
+

See also

+ +
+
+

Author

+ + +

Emanuele Cordano,Guiyun Zhou, Wenyan Dong, and Hongqiang Wei

+
+
+

References

+ + +

Zhou, G., Wei, H. & Fu, S. A fast and simple algorithm for calculating flow accumulation matrices from raster digital elevation. Front. Earth Sci. 13, 317–326 (2019). https://doi.org/10.1007/s11707-018-0725-9 +https://link.springer.com/article/10.1007/s11707-018-0725-9 +Further references: https://ica-abs.copernicus.org/articles/1/434/2019/

+
+ +
+

Examples

+

+
+##source("~/local/rpackages/jrc/terra/R/generics_watershed2_extension.R")
+
+
+elev1 <- array(NA,c(9,9))
+elev2 <- elev1
+
+dx <- 1
+dy <- 1 
+for (r in 1:nrow(elev1)) {
+  y <- (r-5)*dx
+  for (c in 1:ncol(elev1)) {
+    
+    x <- (c-5)*dy
+    elev1[r,c] <- 5*(x^2+y^2)
+    elev2[r,c] <- 10+5*(abs(x))-0.001*y ### 5*(x^2+y^2)
+  }
+} 
+
+
+## Elevation Raster Maps
+elev1 <- rast(elev1)
+elev2 <- rast(elev2)
+##
+weight <- elev1*0+10
+
+t(array(elev1[],rev(dim(elev1)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]  160  125  100   85   80   85  100  125  160
+#>  [2,]  125   90   65   50   45   50   65   90  125
+#>  [3,]  100   65   40   25   20   25   40   65  100
+#>  [4,]   85   50   25   10    5   10   25   50   85
+#>  [5,]   80   45   20    5    0    5   20   45   80
+#>  [6,]   85   50   25   10    5   10   25   50   85
+#>  [7,]  100   65   40   25   20   25   40   65  100
+#>  [8,]  125   90   65   50   45   50   65   90  125
+#>  [9,]  160  125  100   85   80   85  100  125  160
+t(array(elev2[],rev(dim(elev2)[1:2])))
+#>         [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]
+#>  [1,] 30.004 25.004 20.004 15.004 10.004 15.004 20.004 25.004 30.004
+#>  [2,] 30.003 25.003 20.003 15.003 10.003 15.003 20.003 25.003 30.003
+#>  [3,] 30.002 25.002 20.002 15.002 10.002 15.002 20.002 25.002 30.002
+#>  [4,] 30.001 25.001 20.001 15.001 10.001 15.001 20.001 25.001 30.001
+#>  [5,] 30.000 25.000 20.000 15.000 10.000 15.000 20.000 25.000 30.000
+#>  [6,] 29.999 24.999 19.999 14.999  9.999 14.999 19.999 24.999 29.999
+#>  [7,] 29.998 24.998 19.998 14.998  9.998 14.998 19.998 24.998 29.998
+#>  [8,] 29.997 24.997 19.997 14.997  9.997 14.997 19.997 24.997 29.997
+#>  [9,] 29.996 24.996 19.996 14.996  9.996 14.996 19.996 24.996 29.996
+
+plot(elev1)
+
+plot(elev2)
+
+
+## Flow Direction Raster Maps
+flowdir1<- terrain(elev1,v="flowdir")
+flowdir2<- terrain(elev2,v="flowdir")
+
+
+t(array(flowdir1[],rev(dim(flowdir1)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    2    2    2    4    4    4    8    8    8
+#>  [2,]    2    2    2    4    4    4    8    8    8
+#>  [3,]    2    2    2    4    4    4    8    8    8
+#>  [4,]    1    1    1    2    4    8   16   16   16
+#>  [5,]    1    1    1    1    0   16   16   16   16
+#>  [6,]    1    1    1  128   64   32   16   16   16
+#>  [7,]  128  128  128   64   64   64   32   32   32
+#>  [8,]  128  128  128   64   64   64   32   32   32
+#>  [9,]  128  128  128   64   64   64   32   32   32
+t(array(flowdir2[],rev(dim(flowdir2)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    1    1    1    1    4   16   16   16   16
+#>  [2,]    1    1    1    1    4   16   16   16   16
+#>  [3,]    1    1    1    1    4   16   16   16   16
+#>  [4,]    1    1    1    1    4   16   16   16   16
+#>  [5,]    1    1    1    1    4   16   16   16   16
+#>  [6,]    1    1    1    1    4   16   16   16   16
+#>  [7,]    1    1    1    1    4   16   16   16   16
+#>  [8,]    1    1    1    1    4   16   16   16   16
+#>  [9,]    1    1    1    1    0   16   16   16   16
+
+plot(flowdir1)
+
+plot(flowdir2)
+
+
+## 
+
+flow_acc1 <- flowAccu2(flowdir1)
+flow_acc2 <- flowAccu2(flowdir2)
+
+t(array(flow_acc1[],rev(dim(flow_acc1)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    1    1    1    1    1    1    1    1    1
+#>  [2,]    1    2    2    3    2    3    2    2    1
+#>  [3,]    1    2    3    6    3    6    3    2    1
+#>  [4,]    1    3    6   16    4   16    6    3    1
+#>  [5,]    1    2    3    4   81    4    3    2    1
+#>  [6,]    1    3    6   16    4   16    6    3    1
+#>  [7,]    1    2    3    6    3    6    3    2    1
+#>  [8,]    1    2    2    3    2    3    2    2    1
+#>  [9,]    1    1    1    1    1    1    1    1    1
+t(array(flow_acc2[],rev(dim(flow_acc2)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]    1    2    3    4    9    4    3    2    1
+#>  [2,]    1    2    3    4   18    4    3    2    1
+#>  [3,]    1    2    3    4   27    4    3    2    1
+#>  [4,]    1    2    3    4   36    4    3    2    1
+#>  [5,]    1    2    3    4   45    4    3    2    1
+#>  [6,]    1    2    3    4   54    4    3    2    1
+#>  [7,]    1    2    3    4   63    4    3    2    1
+#>  [8,]    1    2    3    4   72    4    3    2    1
+#>  [9,]    1    2    3    4   81    4    3    2    1
+
+plot(flow_acc1)
+
+plot(flow_acc2)
+
+
+
+
+
+flow_acc1w <- flowAccu2_weight(flowdir1,weight)
+flow_acc2w <- flowAccu2_weight(flowdir2,weight)
+
+t(array(flow_acc1w[],rev(dim(flow_acc1w)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]   10   10   10   10   10   10   10   10   10
+#>  [2,]   10   20   20   30   20   30   20   20   10
+#>  [3,]   10   20   30   60   30   60   30   20   10
+#>  [4,]   10   30   60  160   40  160   60   30   10
+#>  [5,]   10   20   30   40  810   40   30   20   10
+#>  [6,]   10   30   60  160   40  160   60   30   10
+#>  [7,]   10   20   30   60   30   60   30   20   10
+#>  [8,]   10   20   20   30   20   30   20   20   10
+#>  [9,]   10   10   10   10   10   10   10   10   10
+t(array(flow_acc2w[],rev(dim(flow_acc2w)[1:2])))
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
+#>  [1,]   10   20   30   40   90   40   30   20   10
+#>  [2,]   10   20   30   40  180   40   30   20   10
+#>  [3,]   10   20   30   40  270   40   30   20   10
+#>  [4,]   10   20   30   40  360   40   30   20   10
+#>  [5,]   10   20   30   40  450   40   30   20   10
+#>  [6,]   10   20   30   40  540   40   30   20   10
+#>  [7,]   10   20   30   40  630   40   30   20   10
+#>  [8,]   10   20   30   40  720   40   30   20   10
+#>  [9,]   10   20   30   40  810   40   30   20   10
+
+plot(flow_acc1w)
+
+plot(flow_acc2w)
+
+
+
+## Application wth example DEM
+
+elev <- rast(system.file('ex/elev.tif',package="terra"))
+flowdir <- terrain(elev,"flowdir")
+
+weight <- cellSize(elev,unit="km")
+flowacc_weight <- flowAccu2_weight(flowdir,weight)
+flowacc  <- flowAccu2(flowdir)
+
+
+
+
+
+
+
+ + +
+ + + + + + + diff --git a/reference/index.html b/reference/index.html index c24075d3c..3ef1a80c9 100644 --- a/reference/index.html +++ b/reference/index.html @@ -67,6 +67,11 @@

All functionsNIDP2(<SpatRaster>) + +
Number of immediate adjacent cells flowing into each cell (Watershed Analysis)
+
+ RGB(<SpatRaster>) `RGB<-`(<SpatRaster>) colorize(<SpatRaster>) has.RGB(<SpatRaster>)
Layers representing colors
@@ -467,6 +472,16 @@

All functionsflowAccu2(<SpatRaster>) + +
Flow accumulation or Total contributing Area (Watershed Analysis)
+

+ + flowAccu2_weight(<SpatRaster>,<SpatRaster>) +
+
Flow accumulation or Total contributing Area (Watershed Analysis)
+
+ focal(<SpatRaster>)
Focal values
@@ -812,6 +827,11 @@

All functionspitfinder2(<SpatRaster>) + +
Pit Finder in a Flow Dir Raster map for Watershed Extraction
+

+ plet(<SpatRaster>) plet(<SpatVector>) plet(<SpatVectorCollection>) lines(<leaflet>) points(<leaflet>)
Plot with leaflet
@@ -1242,6 +1262,11 @@

All functionswatershed2(<SpatRaster>,<integer>) + +
Watershed Extraction
+

+ weighted.mean(<SpatRaster>,<numeric>) weighted.mean(<SpatRaster>,<SpatRaster>)
Weighted mean of layers
diff --git a/reference/makeTiles.html b/reference/makeTiles.html index 92fdcbd70..e3295f7ca 100644 --- a/reference/makeTiles.html +++ b/reference/makeTiles.html @@ -129,10 +129,10 @@

Examplesfilename <- paste0(tempfile(), "_.tif") ff <- makeTiles(r, x, filename) ff -#> [1] "/var/folders/2f/8t5k6yr535sdw0s4glnpxrzm0000gn/T//RtmpWCJY51/file3c9c4fd051cf_1.tif" -#> [2] "/var/folders/2f/8t5k6yr535sdw0s4glnpxrzm0000gn/T//RtmpWCJY51/file3c9c4fd051cf_2.tif" -#> [3] "/var/folders/2f/8t5k6yr535sdw0s4glnpxrzm0000gn/T//RtmpWCJY51/file3c9c4fd051cf_3.tif" -#> [4] "/var/folders/2f/8t5k6yr535sdw0s4glnpxrzm0000gn/T//RtmpWCJY51/file3c9c4fd051cf_4.tif" +#> [1] "/var/folders/2f/8t5k6yr535sdw0s4glnpxrzm0000gn/T//Rtmpr316sw/file33a318ae800f_1.tif" +#> [2] "/var/folders/2f/8t5k6yr535sdw0s4glnpxrzm0000gn/T//Rtmpr316sw/file33a318ae800f_2.tif" +#> [3] "/var/folders/2f/8t5k6yr535sdw0s4glnpxrzm0000gn/T//Rtmpr316sw/file33a318ae800f_3.tif" +#> [4] "/var/folders/2f/8t5k6yr535sdw0s4glnpxrzm0000gn/T//Rtmpr316sw/file33a318ae800f_4.tif" vrt(ff) #> class : SpatRaster @@ -140,8 +140,8 @@

Examples#> resolution : 3.6, 1.8 (x, y) #> extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax) #> coord. ref. : lon/lat WGS 84 (EPSG:4326) -#> source : spat_3c9c332f8922_15516.vrt -#> name : spat_3c9c332f8922_15516 +#> source : spat_33a34513133c_13219.vrt +#> name : spat_33a34513133c_13219 #> min value : 1 #> max value : 10000 diff --git a/reference/mem.html b/reference/mem.html index d28ec2c9a..7e9ad5711 100644 --- a/reference/mem.html +++ b/reference/mem.html @@ -89,8 +89,8 @@

Examples#> Memory (GB) #> ------------------------ #> check threshold : 1 (memmin) -#> available : 3.4 -#> allowed (60%) : 2.04 +#> available : 3.26 +#> allowed (60%) : 1.96 #> needed (n=1) : 0 #> ------------------------ #> proc in memory : TRUE @@ -98,7 +98,7 @@

Examples#> ------------------------ free_RAM() -#> [1] 3569840 +#> [1] 3416640