make_segments: make_segments

View source: R/make_segments.R

make_segmentsR Documentation

make_segments

Description

This function takes a dataframe with coordinates in decimal degrees and a track identifier, and creates line segments for each distinct identifier. If specified, it will generate spatial layers within a gpkg file.

Usage

make_segments(
  df,
  objField = "SEGMID",
  seqField = "POSITION_UTC_DATE",
  lat.field = "LATITUDE",
  lon.field = "LONGITUDE",
  points = "orphans",
  the.crs = "EPSG:4326",
  filename = NULL,
  create.spatial = TRUE,
  gpkgName = "make_segments.gpkg"
)

Arguments

df

default is NULL. This is the dataframe to be processed. It should have coordinates in decimal degrees. It should also have fields for use by objField and seqField.

objField

default is NULL. This is a field identifying which points are part of the same track.

seqField

default is NULL. This is a field which can be used to correctly order the positions along the track (dates are fine).

lat.field

the default is "LATITUDE". the name of the field holding latitude values (in decimal degrees)

lon.field

the default is "LONGITUDE". the name of the field holding longitude values (in decimal degrees)

points

default is "orphans". Valid options include "orphans", "all" and "none". While this function primarily generates linestrings/tracks, it can also include the same data as points/vertices. "none" will not include any vertices, "all" will include all vertices, and "orphans" will only include lone vertices, which are not part of any segment.

the.crs

default is "EPSG:4326". This is the projection you want any generated data to be output in. Input data is assumed to be from a GPS and should be WGS84 (which is what the default value corresponds with).

filename

default is NULL. If you are outputting spatial objects, you can specify a name for them here. This used to correspond with the output shapefile name, but now is used to identify the layers within a gpkg file. They will also get a timestamp.

create.spatial

default is TRUE. This indicates whether or not to create a gpkg file in your working directory.

gpkgName

default is "make_segments.gpkg". If create.spatial = TRUE, a gpkg file will be created, and the name here will control what it is called.

Value

a list containing sf objects. Additionally, a gpkg can be generated.

Author(s)

Mike McMahon, Mike.McMahon@dfo-mpo.gc.ca


Maritimes/Mar.utils documentation built on Aug. 3, 2024, 9:10 p.m.