This function will convert a df into an sf objects.
df2sf(
input = NULL,
lat.field = "latitude",
lon.field = "longitude",
PID = NULL,
ORD = NULL,
epsg = 4326,
type.field = NULL,
point.IDs = NULL,
line.IDs = NULL,
poly.IDs = NULL,
quiet = F
)
Arguments
input |
a df contain coordinates for conversion to sf. |
lat.field |
the default is "latitude" . This is the name of the field holding latitude
values (in decimal degrees) |
lon.field |
the default is "longitude" . This is the name of the field holding
longitude values (in decimal degrees) |
PID |
the default is "PID" . This is a field that uniquely identifies discrete
points, lines, or polygons. |
ORD |
the default is NULL . This is not used if out is "points". This is the
name of a field holding the order in which the provided coordinates should be joined (in lines or
polygons). If nothing is provided, it will be assumed that the data has been provided in the
correct order. |
epsg |
the default is 4326 . This is the coordinate system associated with the input
positions, and it assumes WGS84 (i.e. collected via a GPS). |
type.field |
the default is NULL . This is a field within the data that contains
information about whether each record is a point, line, or polygon. |
point.IDs |
the default is NULL . This is a vector of values from within
type.field that can be used to recognize the point objects (e.g. "station"). |
line.IDs |
the default is NULL . This is a vector of values from within
type.field that can be used to recognize the line objects. |
poly.IDs |
the default is NULL . This is a vector of values from within
type.field that can be used to recognize the polygon objects. |
quiet |
default is F . If 1 PID is found to have multiple positions, by default, a
message is displayed, and information about the points is shown. If this is set to T, no message
or information is shown. |
Value
an sf object
Note
This is a duplicate of what exists in https://github.com/Maritimes/Mar.utils/blob/master/R/df2sf.R.
It is copied, rather than added as a dependency to reduce the number of packages necessary.
Author
Mike McMahon, Mike.McMahon@dfo-mpo.gc.ca