
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.
It needs the measurements resource, so it does not work on a package without it, such as the
Master GeoLocator Data Package or a package read with drop_measurements = TRUE: use the source
package instead.
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, pluslabelandstap_idwhen labels are availablelight: data.frame with columnsdateandvalue, plusstap_idwhen labels are available (if light data available)acceleration: data.frame with columnsdate,value(activity measure), and optionallymean_acceleration_z,label, andstap_id(when labels are 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,acceleration_x,acceleration_y,acceleration_z, plusstap_idwhen labels are available (if magnetic or raw acceleration data available)stap: data.frame with columnsstap_id,start,end, and optionallyknown_latandknown_lon(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/zandacceleration_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, label)light→light(date, value)activity+mean_acceleration_z→acceleration(date, value, mean_acceleration_z, label) where value = activitytemperature_external→temperature_external(date, value)temperature_internal→temperature_internal(date, value)magnetic_x/y/z+acceleration_x/y/z→magnetic(date, magnetic_x/y/z, acceleration_x/y/z)
Additional data extracted:
params.json→tag$paramwhen it contains parameters for the tagstapstable →tag$stap(stap_id, start, end, known_lat, known_lon)twilightstable →tag$twilight(twilight, rise, label)
Saved parameters are returned as a GeoPressureR param object, in the layout they were
saved with (read packages are moved to the GeoPressureR >= 3.8.0 layout, with logger
metadata in tag_create$settings). When the package has no saved parameters for the tag,
or they do not record its manufacturer, tag$param$tag_create$manufacturer
is set to "datapackage" to record where the data came from. It is not a manufacturer that
GeoPressureR::tag_create() accepts, so the tag cannot be re-created from these parameters.
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 = "22PH")
# Convert multiple specific tags
tags <- gldp_to_tag(pkg, tag_id = c("22PH", "22PO"))
} # }