Skip to contents

read_with_scheme() is a wrapper for more specific functions. It uses type and extension to call the good function. If those parameters are not specified it tries to guess them from the name of the archive included in x.

read_csv_with_scheme() relies on data.table::fread to read tabular data, and to apply a scheme. The idea is to used the efficiency of fread() to read more quickly data (and without too many specifications on "sep" and "dec"), and to used some options to read only data that will be kept with original format given in scheme. As almost, everyhting is done after reading, the remaining part of applying a scheme is also one: final format is applied, and if, some "lon" and "lat" is found, data is transformed in sf object.

read_shp_with_scheme() relies on sf::st_read to read gpkg data. If given, projection is changed. If given scheme is applyed through apply_scheme(). It is supposed that the scheme given is organized with a layer column.

read_gpkg_with_scheme() relies on sf::st_read to read gpkg data. If given, projection is changed. If given scheme is applyed through apply_scheme(). It is supposed that the scheme given is organized with a layer column.

read_shp_from_7z uses a system call to 7z to uncompress a 7z archive. It looks specifically for files that correspond to given layer. It then reads the uncompressed gpkg file with a call to read_shp_with_scheme().

read_gkpg_from_7z uses a system call to 7z to uncompress a 7z archive. It looks specifically for files with extension gkpg, and presumes that there is only one. It then reads the uncompressed gpkg file with a call to read_gpkg_with_scheme().

Usage

read_with_scheme(
  x,
  scheme = NULL,
  projection = NA,
  layer,
  type,
  extension = tools::file_ext(x)
)

read_csv_with_scheme(x, scheme = NULL, projection = NA)

read_shp_with_scheme(x, scheme = NULL, projection = NA, layer)

read_gpkg_with_scheme(x, scheme = NULL, projection = NA, layer)

read_shp_from_7z(x, scheme = NULL, projection = NA, layer)

read_gpkg_from_7z(x, scheme = NULL, projection = NA, layer)

Arguments

x

character, path of the data to be read.

scheme

data.frame, scheme to be applied.

projection

something that will be used in the option "crs" of sf::st_as_sf.

layer

character, indicates the layer to be read for data organized by layers.

type

character, indicates the type of data that should be read.

extension

character, indicate the exrtension of the archive. If missing will be guessed from x.

Value

data adapted, either a data.frame or a 'sf' objects.

Details

If 'scheme' is NULL (default). data.table::fread is used with colClasses set to "character".

If 'projection' is NA (default), no crs is given sf::to st_as_sf.