Skip to contents

This function creates a sf object using the point geometry, based on the NDS-BR naturalistic data (see nds_load_data).

Usage

nds_create_points(data, x, y, valid = "all")

Arguments

data

A data.frame or tibble object with coordinates.

x

Data attribute with x coordinates.

y

Data attribute with y coordinates.

valid

Option to select all data or valid data ("all", "yes").

Value

A sf object with point geometry

Details

nds_create_points takes the naturalistic data as input and creates a point spatial object. x and y arguments considers longitude and latitude, respectively. It is possible to filter only valid time data using the valid parameter. In it's default, the function transforms all data, including invalid times.

See also

Examples

path <- system.file("extdata", package = "ndsbr")
nds_data <- nds_load_data("driver", path)
#>  Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#>  Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#>  Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
nds_create_points(nds_data, x = LONG, y = LAT)
#> Simple feature collection with 18012 features and 32 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -49.33385 ymin: -25.5531 xmax: -49.18389 ymax: -25.37371
#> Geodetic CRS:  SIRGAS 2000
#> # A tibble: 18,012 × 33
#>    DRIVER DAY       DAY_CORRIGIDO `03:00:00`  TRIP ID    PR        H     M     S
#>  * <chr>  <chr>     <chr>         <chr>      <dbl> <chr> <chr> <dbl> <dbl> <dbl>
#>  1 A      26/8/2019 26/8/2019     22:17:27       5 A05   19:1…    NA    NA    NA
#>  2 A      26/8/2019 26/8/2019     22:17:28       5 A05   19:1…     0     0     1
#>  3 A      26/8/2019 26/8/2019     22:17:29       5 A05   19:1…     0     0     1
#>  4 A      26/8/2019 26/8/2019     22:17:30       5 A05   19:1…     0     0     1
#>  5 A      26/8/2019 26/8/2019     22:17:31       5 A05   19:1…     0     0     1
#>  6 A      26/8/2019 26/8/2019     22:17:32       5 A05   19:1…     0     0     1
#>  7 A      26/8/2019 26/8/2019     22:17:33       5 A05   19:1…     0     0     1
#>  8 A      26/8/2019 26/8/2019     22:17:34       5 A05   19:1…     0     0     1
#>  9 A      26/8/2019 26/8/2019     22:17:35       5 A05   19:1…     0     0     1
#> 10 A      26/8/2019 26/8/2019     22:17:36       5 A05   19:1…     0     0     1
#> # ℹ 18,002 more rows
#> # ℹ 23 more variables: TIME_ACUM <dbl>, SPD_MPH <dbl>, SPD_KMH <dbl>,
#> #   ACEL_MS2 <dbl>, HEADING <dbl>, ALTITUDE_FT <dbl>, VALID_TIME <chr>,
#> #   TIMESTAMP_GPS <chr>, CPOOL <chr>, CPOOLING_CHECKED <chr>, WSB <chr>,
#> #   UMP_YN <chr>, UMP <chr>, PICK_UP <chr>, ACTION <chr>, GPS_FILE <chr>,
#> #   CIDADE <chr>, BAIRRO <chr>, NOME_RUA <chr>, HIERARQUIA_CWB <chr>,
#> #   HIERARQUIA_CTB <chr>, LIMITE_VEL <chr>, geometry <POINT [°]>