view val_metadata.r @ 0:a8dabbf47e15 draft

planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
author ecology
date Mon, 09 Jan 2023 13:39:08 +0000
parents
children
line wrap: on
line source

#Rscript

############################################
##  Validate ISO 19139 metadata documen   ##
############################################

#####Packages : ncdf4,
#               geometa,
#               httr
#               xml
#               xml2
library(geometa)

#####Load arguments

args <- commandArgs(trailingOnly = TRUE)

if (length(args) < 1) {
    stop("This tool needs at least 1 argument")
}else {
    input_data <- args[1]
}

##------------------------------------------##
##      Read ISO 19139 from a file or url   ##
##------------------------------------------##

# Test depuis catalogue Indores http://indores-tmp.in2p3.fr/geonetwork/srv/fre/catalog.search#/metadata/112ebeea-e79c-422c-8a43-a5a8323b446b
# <!--ISO 19139 XML compliance: NO-->
input_data <- xml2::read_xml(input_data)

dir.create("results")
file.create("results/meta.xml")

xml2::write_xml(input_data, file = "results/meta.xml")

md <- geometa::readISO19139("results/meta.xml")


# validate iso
cat("\nValidation of metadata according to ISO 19139\n", md$validate(), file = "Metadata_validation.txt", fill = 1, append = FALSE)