annotate val_metadata.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 ## Validate ISO 19139 metadata documen ##
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 : ncdf4,
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
8 # geometa,
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
9 # httr
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
10 # xml
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
11 # xml2
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
12 library(geometa)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
13
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
14 #####Load arguments
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
15
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
16 args <- commandArgs(trailingOnly = TRUE)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
17
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
18 if (length(args) < 1) {
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
19 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
20 }else {
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
21 input_data <- args[1]
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
22 }
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
23
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
24 ##------------------------------------------##
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
25 ## Read ISO 19139 from a file or url ##
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
26 ##------------------------------------------##
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 # Test depuis catalogue Indores http://indores-tmp.in2p3.fr/geonetwork/srv/fre/catalog.search#/metadata/112ebeea-e79c-422c-8a43-a5a8323b446b
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
29 # <!--ISO 19139 XML compliance: NO-->
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
30 input_data <- xml2::read_xml(input_data)
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
31
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
32 dir.create("results")
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
33 file.create("results/meta.xml")
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
34
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
35 xml2::write_xml(input_data, file = "results/meta.xml")
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
36
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
37 md <- geometa::readISO19139("results/meta.xml")
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
38
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
39
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
40 # validate iso
054b2522a933 planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
ecology
parents:
diff changeset
41 cat("\nValidation of metadata according to ISO 19139\n", md$validate(), file = "Metadata_validation.txt", fill = 1, append = FALSE)