
Convert GeoLocator Data Package to GeoPressureR tag object(s)
Source:R/gldp_to_tag.R
gldp_to_tag.RdThis function converts a GeoLocator Data Package (GLDP) object to one or more GeoPressureR
tag objects. A GLDP can contain data for multiple tags, while each
GeoPressureR tag object represents a single tag's sensor data.
Arguments
- pkg
A GeoLocator Data Package object (class
"geolocatordp"), typically created withread_gldp()orcreate_gldp().- tag_id
Character vector specifying which tag(s) to extract. If
NULL(default), all tags in the package are converted.
Value
If tag_id is a single value or if the package contains only one tag, returns a single
GeoPressureR tag object. Otherwise, returns a named list of tag objects, where names
correspond to the tag_id values.
A GeoPressureR tag object contains:
param: parameter object (seeGeoPressureR::param_create())pressure: data.frame with columnsdateandvalue(if pressure data available)light: data.frame with columnsdateandvalue(if light data available)acceleration: data.frame with columnsdate,value(activity measure), and optionallymean_acceleration_z(if available)temperature_external: data.frame with columnsdateandvalue(if external temperature data available)temperature_internal: data.frame with columnsdateandvalue(if internal temperature data available)magnetic: data.frame with columnsdate,magnetic_x,magnetic_y,magnetic_z(if magnetic data available)stap: data.frame with columnsstap_id,start,end, and optionallyknown_lat,known_lon,include(if stationary periods defined)twilight: data.frame with columnstwilight,rise, and optionallylabel(if twilight data available)
Details
The function extracts sensor data from the GLDP measurements resource and converts it
to the format expected by GeoPressureR. The conversion includes:
Filtering measurements by
tag_idReshaping data from long format (measurements) to wide format (sensor-specific data.frames)
Combining related sensors (e.g.,
activityandmean_acceleration_zintoacceleration;magnetic_x/y/zintomagnetic)Adding stationary period (
stap) data if available in the packageAdding twilight data if available in the package
Setting appropriate parameter values from GLDP metadata
Sensor mapping from GLDP to GeoPressureR:
pressure→pressure(date, value)light→light(date, value)activity+mean_acceleration_z→acceleration(date, value, mean_acceleration_z) where value = activitytemperature-external→temperature_external(date, value)temperature-internal→temperature_internal(date, value)magnetic_x/y/z→magnetic(date, magnetic_x, magnetic_y, magnetic_z)
Additional data extracted:
stapstable →tag$stap(stap_id, start, end, known_lat, known_lon, include)twilightstable →tag$twilight(twilight, rise, label)
Note that the resulting tag object will have manufacturer = "datapackage" in its
parameters, consistent with how GeoPressureR handles data from GeoLocator Data Packages.
See also
read_gldp()for reading a GeoLocator Data PackageGeoPressureR::tag_create()for creating tag objects from raw files
Examples
if (FALSE) { # \dontrun{
# Read a GLDP from Zenodo
pkg <- read_zenodo("17367319", quiet = TRUE)
# Convert all tags
tags <- gldp_to_tag(pkg)
# Convert a specific tag
tag <- gldp_to_tag(pkg, tag_id = "18LX")
# Convert multiple specific tags
tags <- gldp_to_tag(pkg, tag_id = c("18LX", "18IC"))
} # }