MetaEgress
to generate EML document from LTER-core-metabaseusage_example.Rmd
Last updated: 15 November, 2019
This is an example workflow from metabase to EML document. This guide assumes you have an installed and populated instance of LTER-core-metabase, plus log-in credentials for an user with at least read or SELECT access to this database. See the LTER-core-metabase Github repository for information on installation and population. If you would like to test drive MetaEgress
, use the database dump specifically made for this purpose; see this document.
(aside from well populated metabase)
DataSet.Abstract
.DataSetMethods.methodDocument
.DataSetEntities.FileName
.Note on document formats
MetaEgress
uses the function set_TextType
from the EML R package to wrap documents in XML tags. See set_TextType
documentation to learn more about compatible formats: ?EML::set_TextType
.
# View documentation
?get_meta
# Use function
metadata <-
get_meta(
dbname = "metabase", # change to your DB name
schema = "mb2eml_r", # change to schema containing views
dataset_ids = 1, # change to ID or numeric vector of IDs wanted
host = "localhost", # change to IP address if remote host
port = 5432,
user = NULL, # change to username and password to save time or if not using RStudio
password = NULL # if NULL, RStudio will create pop-up windows asking for username and password
)
# View documentation
?create_entity_all
# Use the function
entities <- create_entity_all(
meta_list = metadata, # list returned by `get_meta`
dataset_id = 1, # a singular dataset ID
file_dir = getwd() # directory containing data files
)
Note that even if the function runs successfully, many warnings will be generated. Use warnings()
to see them. Most of the time the warnings will concern custom units and can safely be ignored.
First validate EML document using the function eml_validate
from EML R package. The input could be an EML list object or output from create_entity
, or a XML file.
Desired outcome is TRUE:
[1] TRUE attr(,“errors”) character(0)
Should eml_validate
return FALSE, examine the list object returned by create_EML
. Error messages generated by eml_validate
could be quite cryptic and might not point to the real problem.
Then serialize or write to XML file using the function write_eml
from the EML R package.