df_to_sf: df_to_sf

View source: R/df_to_sf.R

df_to_sfR Documentation

df_to_sf

Description

This function will accept a dataframe and turn it into an sf object of class "POLYGON", "LINESTRING" or "POINTS". It can handle PBSMapping polysets or any appropriately structured dataframe.

Usage

df_to_sf(
  df = NULL,
  lat.field = "LATITUDE",
  lon.field = "LONGITUDE",
  primary.object.field = "PID",
  secondary.object.field = "SID",
  order.field = "POS",
  type = "polys"
)

Arguments

df

the default is NULL. This is a dataframe that has coordinates holding latitudes and longtitudes in decimal degrees.

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)

primary.object.field

the default is "PID". If polygons or lines are specified, this field is used to identify discrete objects.

secondary.object.field

the default is "SID". Complex polygons need this additional identifier in order to create objects such as polygons with holes.

order.field

the default is "POS". This parameter specifies the field that controls the order points should be joined. In order to specifiy a "hole", the order field for the c oordinates specifying the hole should be descending (rather than ascending).

type

the default is "polys", but it can also be "lines" or "points"

Value

an sf object

Note

this function was modified from https://github.com/Mar-scal/Assessment_fns/blob/master/Maps/pbs_2_sf.R

Author(s)

Dave Keith Dave.Keith@dfo-mpo.gc.ca, Freya Keyser Freya.Keyser@dfo-mpo.gc.ca and adapted by Mike McMahon Mike.McMahon@dfo-mpo.gc.ca

See Also

Other general_use: DDMMSS_to_DD(), DDMMx_to_DD(), aggregator(), clip_by_poly(), combine_lists(), df_qc_spatial(), df_sf_to_gpkg(), drop_cols(), prepare_shape_fields(), subset_by_time(), updateCheck()


Maritimes/Mar.utils documentation built on Feb. 12, 2024, 11:38 p.m.