annotate biodiv_indices_global.r @ 0:054b2522a933 draft default tip

planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
author ecology
date Mon, 09 Jan 2023 13:38:38 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
1 #Rscript
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
2
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
3 ###########################################
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
4 ## Mapping biodiversity indicators ##
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
5 ###########################################
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
6
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
7 #####Packages : raster,
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
8 # rgdal,
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
9 # sp,
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
10 # rasterdiv,
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
11 # ggplot2,
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
12
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
13 #####Load arguments
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
14
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
15 args <- commandArgs(trailingOnly = TRUE)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
16
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
17 #####Import the S2 data
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
18
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
19 if (length(args) < 1) {
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
20 stop("This tool needs at least 1 argument")
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
21 }else {
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
22 data_raster <- args[1]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
23 data_header <- args[2]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
24 data <- args[3]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
25 alpha <- as.numeric(args[4])
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
26 source(args[5])
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
27
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
28 }
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
29
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
30 ########################################################################
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
31 ## COMPUTE BIODIVERSITY INDICES ##
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
32 ########################################################################
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
33
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
34 if (data_raster == "") {
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
35 #Create a directory where to unzip your folder of data
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
36 dir.create("data_dir")
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
37 unzip(data, exdir = "data_dir")
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
38 # Path to raster
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
39 data_raster <- list.files("data_dir/results/Reflectance", pattern = "_Refl")
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
40 data_raster <- file.path("data_dir/results/Reflectance", data_raster[1])
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
41 }
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
42
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
43 # Read raster
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
44 copndvi <- raster::raster(data_raster)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
45
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
46 copndvilr <- raster::reclassify(copndvi, cbind(252, 255, NA), right = TRUE)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
47
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
48 #Resample using raster::aggregate and a linear factor of 10
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
49 copndvilr <- raster::aggregate(copndvilr, fact = 20)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
50 #Set float numbers as integers to further speed up the calculation
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
51 storage.mode(copndvilr[]) <- "integer"
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
52
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
53 # Convert raster to SpatialPointsDataFrame
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
54 r_pts <- convert_raster(copndvilr)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
55
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
56 #Shannon's Diversity
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
57 sha <- rasterdiv::Shannon(copndvilr, window = 9, np = 1)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
58 sha_df <- data.frame(raster::rasterToPoints(sha, spatial = TRUE))
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
59 sha_name <- "Shannon"
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
60 r_pts[, sha_name] <- sha_df[, 1]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
61
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
62 #Renyi's Index
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
63 ren <- rasterdiv::Renyi(copndvilr, window = 9, alpha = alpha, np = 1)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
64 ren_df <- data.frame(raster::rasterToPoints(ren[[1]]))
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
65 ren_name <- "Renyi"
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
66 r_pts[, ren_name] <- ren_df[, 3]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
67
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
68 #Berger-Parker's Index
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
69 ber <- rasterdiv::BergerParker(copndvilr, window = 9, np = 1)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
70 ber_df <- data.frame(raster::rasterToPoints(ber, spatial = TRUE))
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
71 ber_name <- "Berger-Parker"
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
72 r_pts[, ber_name] <- ber_df[, 1]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
73
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
74 #Pielou's Evenness
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
75 pie <- rasterdiv::Pielou(copndvilr, window = 9, np = 1)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
76 pie_df <- data.frame(raster::rasterToPoints(pie))
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
77 if (length(pie_df[, 1]) == length(r_pts[, 1])) {
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
78 pie_name <- "Pielou"
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
79 r_pts[, pie_name] <- pie_df[, 1]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
80 }
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
81
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
82 #Hill's numbers
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
83 hil <- rasterdiv::Hill(copndvilr, window = 9, alpha = alpha, np = 1)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
84 hil_df <- data.frame(raster::rasterToPoints(hil[[1]]))
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
85 hil_name <- "Hill"
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
86 r_pts[, hil_name] <- hil_df[, 3]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
87
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
88 #Parametric Rao's quadratic entropy with alpha ranging from 1 to 5
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
89 prao <- rasterdiv::paRao(copndvilr, window = 9, alpha = alpha, dist_m = "euclidean", np = 1)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
90 prao_df <- data.frame(raster::rasterToPoints(prao$window.9[[1]]))
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
91 prao_name <- "Prao"
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
92 r_pts[, prao_name] <- prao_df[, 3]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
93
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
94 #Cumulative Residual Entropy
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
95 cre <- rasterdiv::CRE(copndvilr, window = 9, np = 1)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
96 cre_df <- data.frame(raster::rasterToPoints(cre))
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
97 if (length(cre_df[, 1]) == length(r_pts[, 1])) {
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
98 cre_name <- "CRE"
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
99 r_pts[, cre_name] <- cre_df[, 1]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
100 }
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
101
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
102 if (length(cre_df[, 1]) == length(r_pts[, 1]) || length(pie_df[, 1]) == length(r_pts[, 1])) {
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
103 list_indice <- list("Shannon", "Renyi", "Berger-Parker", "Pielou", "Hill", "Prao", "CRE")
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
104 } else {
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
105 list_indice <- list("Shannon", "Renyi", "Berger-Parker", "Hill", "Prao")
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
106 }
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
107 ## Plotting all the graph and writing a tabular
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
108 for (indice in list_indice) {
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
109 plot_indices(data = r_pts, titre = indice)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
110 }
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
111
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
112 write.table(r_pts, file = "BiodivIndex.tabular", sep = "\t", dec = ".", na = " ", row.names = FALSE, col.names = TRUE, quote = FALSE)