WriteHarmonizedSpatialDescription: Write a Harmonized Spatial Description File

View source: R/functioncollection_Harmonized.R

WriteHarmonizedSpatialDescriptionR Documentation

Write a Harmonized Spatial Description File

Description

This is a convenience wrapper function to export a data frame to the required Harmonized Spatial Description File format. See the HYPEObsMetadataTools documentation.

Usage

WriteHarmonizedSpatialDescription(
  df,
  filename = "",
  replace.accents = FALSE,
  strip.punctuation = FALSE,
  ignore.cols = NULL,
  nThread = getDTthreads()
)

Arguments

df

Data frame containing the harmonized spatial description data.

filename

Path to and file name (including ".csv" file extension) of the Harmonized Spatial Description CSV file to export. Windows users: Note that Paths are separated by '/', not '\'.

replace.accents

Logical, if TRUE, then accented characters (e.g. ä, ö, å) will be replaced with non-accented characters in all strings. If FALSE, then strings will be left unmodified.

strip.punctuation

Logical, if TRUE, then punctuation characters (e.g. "-", ".", ".") will be removed from all strings. If FALSE, then strings will be left unmodified.

ignore.cols

Vector of columns in df that should be ignored when replace.accents or strip.punctuation are set to TRUE.

nThread

Integer, set number of threads to be used when writing file. See getDTthreads

Details

WriteHarmonizedSpatialDescription is a convenience wrapper function of fread to export harmonized spatial description data in the HYPEObsMetadataTools Harmonized Spatial Description Format. The function checks that all required columns are present, includes options to format strings, and exports data to output CSV files with the correct encoding and formatting.

Value

WriteSpatialDescrption exports a CSV file if filename is specified. Otherwise, the function outputs a data frame to the console.

Examples

df <- data.frame(
  "STATION_ID" = "A1",
  "SRC_NAME" = "Example",
  "DOWNLOAD_DATE" = "2022-10-19",
  "SRC_STATNAME" = "Station",
  "SRC_WBNAME" = "River",
  "SRC_UAREA" = NA,
  "SRC_XCOORD" = 28.11831,
  "SRC_YCOORD" = -25.83053,
  "SRC_EPSG" = 4326,
  "ADJ_XCOORD" = 28.11831,
  "ADJ_YCOORD" = -25.83053,
  "ADJ_EPSG" = 4326
)

WriteHarmonizedSpatialDescription(df)


rcapell/RHYPE documentation built on Feb. 28, 2024, 3:11 p.m.