df_sf_to_gpkg: df_sf_to_gpkg

View source: R/df_sf_to_gpkg.R

df_sf_to_gpkgR Documentation

df_sf_to_gpkg

Description

This function adds dataframes (with coordinates) and/or sf spatial objects into a gpkg file. Dataframes will be converted into sf POINT objects, but if existing sf objects are submitted, they will be added to the gpkg file.

Usage

df_sf_to_gpkg(
  df = NULL,
  lat.field = "LATITUDE",
  lon.field = "LONGITUDE",
  crs = 4326,
  makeSpatial = T,
  path = NULL,
  layerName = NULL,
  gpkgName = "r_layers.gpkg"
)

Arguments

df

the default is NULL a dataframe or sf object to be added to a gpkg file

lat.field

the default is "LATITUDE". For dataframe objects, this is the name of the field holding latitude values (in decimal degrees). This field can be ignored if the submitted df is an sf object.

lon.field

the default is "LONGITUDE". For dataframe objects, this is the name of the field holding longitude values (in decimal degrees). This field can be ignored if the submitted df is an sf object.

crs

the default is 4326. This is the coordinate system associated with the input positions, and it assumes WGS84 (i.e. collected via a GPS). This field can be ignored if the submitted df is an sf object.

makeSpatial

the default is TRUE. By default, this function will attempt to convert dataframes to spatial (i.e. sf) objects. Set this to false if you just want tabular data.

path

this is the path to the gpkg file (e.g. "c:/folder/")

layerName

the default is NULL. This will be the name of the layer within the gpkg file (not the name of the generated gpkg file.)

gpkgName

the default is "r_layers.gpkg". This is the name of the gpkg file that will hold the spatial layers. If this file already exists in path, the layer will be added to the existing file. If the file does not exist, it will be created.

Value

NULL - writes shapefile to current working directory

Author(s)

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_to_sf(), drop_cols(), prepare_shape_fields(), subset_by_time(), updateCheck()


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