Mercurial > repos > ecology > srs_global_indices
annotate indices_spectral.r @ 0:5cae678042ec 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:36:33 +0000 |
parents | |
children |
rev | line source |
---|---|
0
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
1 #Rscript |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
2 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
3 ########################################### |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
4 ## Mapping alpha and beta diversity ## |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
5 ########################################### |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
6 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
7 #####Packages : expint, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
8 # pracma, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
9 # R.utils, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
10 # raster, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
11 # sp, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
12 # matrixStats, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
13 # ggplot2, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
14 # expandFunctions, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
15 # stringr, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
16 # XML, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
17 # rgdal, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
18 # stars, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
19 #####Load arguments |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
20 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
21 args <- commandArgs(trailingOnly = TRUE) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
22 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
23 #####Import the S2 data |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
24 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
25 if (length(args) < 1) { |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
26 stop("This tool needs at least 1 argument") |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
27 }else { |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
28 data_raster <- args[1] |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
29 data_header <- args[2] |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
30 data <- args[3] |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
31 source(args[4]) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
32 source(args[5]) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
33 source(args[6]) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
34 indice_choice <- strsplit(args[7], ",")[[1]] |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
35 source(args[8]) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
36 output_raster <- as.character(args[9]) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
37 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
38 } |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
39 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
40 ######################################################################## |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
41 ## COMPUTE SPECTRAL INDEX : NDVI ## |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
42 ######################################################################## |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
43 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
44 if (data != "") { |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
45 #Create a directory where to unzip your folder of data |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
46 dir.create("data_dir") |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
47 unzip(data, exdir = "data_dir") |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
48 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
49 # Read raster |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
50 data_raster <- list.files("data_dir/results/Reflectance", pattern = "_Refl") |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
51 data_raster <- file.path("data_dir/results/Reflectance", data_raster[1]) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
52 refl <- raster::brick(data_raster) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
53 refl2 <- raster::raster(data_raster) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
54 } else { |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
55 # Read raster |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
56 refl <- raster::brick(data_raster) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
57 refl2 <- raster::raster(data_raster) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
58 } |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
59 # get raster band name and clean format. Expecting band name and wav |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
60 # reflFactor = 10000 when reflectance is coded as INT16 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
61 refl <- raster::aggregate(refl, fact = 10) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
62 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
63 # Convert raster to SpatialPointsDataFrame |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
64 refl2 <- raster::aggregate(refl2, fact = 10) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
65 r_pts <- convert_raster(refl2) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
66 table_ind <- r_pts |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
67 # create directory for Spectralelength to be documented in image |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
68 hdr_refl <- read_envi_header(get_hdr_name(data_raster)) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
69 sensorbands <- hdr_refl$wavelength |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
70 # compute a set of spectral indices defined by indexlist from S2 data indices |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
71 si_path <- file.path("SpectralIndices") |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
72 dir.create(path = si_path, showWarnings = FALSE, recursive = TRUE) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
73 # Save spectral indices |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
74 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
75 indices <- lapply(indice_choice, function(x) { |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
76 indices_list <- computespectralindices_raster(refl = refl, sensorbands = sensorbands, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
77 sel_indices = x, |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
78 reflfactor = 10000, stackout = FALSE) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
79 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
80 index_path <- file.path(si_path, paste(basename(data_raster), "_", x, sep = "")) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
81 spec_indices <- stars::write_stars(stars::st_as_stars(indices_list$spectralindices[[1]]), dsn = index_path, driver = "ENVI", type = "Float32") |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
82 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
83 # write band name in HDR |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
84 hdr <- read_envi_header(get_hdr_name(index_path)) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
85 hdr$`band names` <- x |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
86 write_envi_header(hdr = hdr, hdrpath = get_hdr_name(index_path)) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
87 # Writting the tabular and the plot |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
88 r_pts[, x] <- as.data.frame(sapply(spec_indices, c)) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
89 plot_indices(data = r_pts, titre = x) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
90 return(r_pts) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
91 }) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
92 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
93 new_table <- as.data.frame(indices) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
94 new_table <- new_table[, !grepl("longitude", names(new_table))] |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
95 new_table <- new_table[, !grepl("latitude", names(new_table))] |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
96 new_table <- new_table[, !grepl(basename(data_raster), names(new_table))] |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
97 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
98 table_ind <- cbind(table_ind, new_table) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
99 if (length(indice_choice) == 1) { |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
100 colnames(table_ind) <- c(basename(data_raster), "longitude", "latitude", indice_choice) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
101 } |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
102 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
103 write.table(table_ind, file = "Spec_Index.tabular", sep = "\t", dec = ".", na = " ", row.names = FALSE, col.names = TRUE, quote = FALSE) |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
104 |
5cae678042ec
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff
changeset
|
105 # Get the raster layer of the indice as an output |