knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
options(knitr.table.format = "html", rmarkdown.html_vignette.check_title = FALSE)

library(eRTG3D)
set.seed(123)

The sf package delivers a standardized way to encode spatial vector data, the so called Simple Features (SF). It binds to GDAL for reading and writing data, to GEOS for geometrical operations, and to Proj.4 for projection conversions and datum transformations. Therefore the eRTG3D package comes with some wrapper functions to convert the generated tracks to simple features. The resulting sf, data.frame objects enable access to the functionality of the sf package, which also includes an easy way to access spatial databases (PostGIS).

Convert to sf

To convert tracks to a an object of type sf, data.frame use the track2sf.3d() function, which can take data.frames, matrices and move objects (containing one track!) as input. In case of data.frames and matrices, it is important that the coordinates are stored in the first three rows.

niclas <- track2sf.3d(niclas, CRS = 2056)
is.sf.3d(niclas)
head(niclas, 3)

Convert from sf

To test if a track is of type sf, data.frame use the is.sf() function, and to convert a sf, data.frame back to a track data.frame use sf2df.3d().

niclas <- sf2df.3d(niclas)
is.sf.3d(niclas)


munterfinger/eRTG3D documentation built on March 25, 2022, 1:22 a.m.