save_data: save_data

View source: R/save_data.r

save_dataR Documentation

save_data

Description

This function takes either a dataframe or all of the data you've filtered, and rolls it up into a csv and/ or a shapefile for continued analysis

Usage

save_data(
  db = NULL,
  df = NULL,
  filename = NULL,
  df.crs = "EPSG:4326",
  req.coords = TRUE,
  lat.field = "LATITUDE",
  lon.field = "LONGITUDE",
  formats = c("csv", "gpkg"),
  env = .GlobalEnv
)

Arguments

db

default is NULL. This identifies the dataset you are working with.

df

This is a dataframe that you want to save in some other format. If a spatial format is selected (e.g. shapefile), it must have LATITUDE and LONGITUDE fields

filename

default is NULL. This will be the prefix of your filename

df.crs

This is the CRS value for your dataframe. This should be the reference system that your data is known to be in. The default value "EPSG:4326" is WGS84 and is appropriate for most data collected using a GPS.

req.coords

default is TRUE. This filters out records without values for LATITUDE or LONGITUDE. The function aborts if req.coords=TRUE and no records remain.

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)

formats

This is a vector of the formats in which you would like to save the current data, including "raw" for a (local) dataframe, "sf" for a (local) simple feature object, "gpkg" for an ESRI-compatible geopackage or "csv" (both written to the wd). The raw and sp objects will just have the name specified by filename, while the csv also gets a timestamp, since it's written externally .

env

This the the environment you want this function to work in. The default value is .GlobalEnv.

Note

Note that with the retirement of rgeos, rgdal and maptools, shapefiles are no longer supported by this package. Instead, gpkg file are generated. Additionally sp objects are also being phased out and are being replaced by sf objects.

Author(s)

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

See Also

Other general_use: cleanup(), get_isdb_trip_set(), restore_tables(), save_tables()


Maritimes/Mar.datawrangling documentation built on Feb. 6, 2024, 3:25 a.m.