Skip to contents

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

Usage

nds_create_lines(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 linestring geometry.

Details

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

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_lines(nds_data, x = LONG, y = LAT)
#> Simple feature collection with 17985 features and 34 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: -49.33385 ymin: -25.5531 xmax: -49.18389 ymax: -25.37371
#> Geodetic CRS:  SIRGAS 2000
#> # A tibble: 17,985 × 35
#>    DRIVER  LONG   LAT DAY       DAY_CORRIGIDO `03:00:00`  TRIP ID    PR        H
#>  * <chr>  <dbl> <dbl> <chr>     <chr>         <chr>      <dbl> <chr> <chr> <dbl>
#>  1 A      -49.2 -25.5 26/8/2019 26/8/2019     22:17:28       5 A05   19:1…     0
#>  2 A      -49.2 -25.5 26/8/2019 26/8/2019     22:17:29       5 A05   19:1…     0
#>  3 A      -49.2 -25.5 26/8/2019 26/8/2019     22:17:30       5 A05   19:1…     0
#>  4 A      -49.2 -25.5 26/8/2019 26/8/2019     22:17:31       5 A05   19:1…     0
#>  5 A      -49.2 -25.5 26/8/2019 26/8/2019     22:17:32       5 A05   19:1…     0
#>  6 A      -49.2 -25.5 26/8/2019 26/8/2019     22:17:33       5 A05   19:1…     0
#>  7 A      -49.2 -25.5 26/8/2019 26/8/2019     22:17:34       5 A05   19:1…     0
#>  8 A      -49.2 -25.5 26/8/2019 26/8/2019     22:17:35       5 A05   19:1…     0
#>  9 A      -49.2 -25.5 26/8/2019 26/8/2019     22:17:36       5 A05   19:1…     0
#> 10 A      -49.2 -25.5 26/8/2019 26/8/2019     22:17:37       5 A05   19:1…     0
#> # ℹ 17,975 more rows
#> # ℹ 25 more variables: M <dbl>, S <dbl>, 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>, …