
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. The gldp structure contains data for potentially 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 optionallypitch(if activity/pitch data 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's 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.,
activityandpitchintoacceleration;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 the gldp metadata
Sensor mapping from GLDP to GeoPressureR:
pressure→pressure(date, value)light→light(date, value)activity+pitch→acceleration(date, value, pitch) 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