Write data to a GeoPackage

gpkg_write(
  x,
  destfile,
  table_name = NULL,
  datatype = "FLT4S",
  append = FALSE,
  overwrite = FALSE,
  NoData = NULL,
  gdal_options = NULL,
  ...
)

Arguments

x

Vector of source file path(s), or a list containing one or more SpatRaster, SpatRasterCollection, or SpatVectorProxy objects.

destfile

Character. Path to output GeoPackage

table_name

Character. Default NULL name is derived from source file. Required if x is a data.frame.

datatype

Data type. Defaults to "FLT4S" for GeoTIFF files, "INT2U" otherwise. See documentation for terra::writeRaster().

append

Append to existing data source? Default: FALSE. Setting append=TRUE overrides overwrite=TRUE

overwrite

Overwrite existing data source? Default FALSE.

NoData

Value to use as GDAL NoData Value

gdal_options

Additional gdal_options, passed to terra::writeRaster()

...

Additional arguments are passed as GeoPackage "creation options." See Details.

Value

Logical. TRUE on successful write of at least one grid.

Details

Additional, non-default GeoPackage creation options can be specified as arguments to this function. The full list of creation options can be viewed here or in the gpkg_creation_options dataset. The name of the argument is creation_option and the value is selected from one of the elements of values for that option.

If x contains source file paths, any comma-separated value (CSV) files are treated as attribute data--even if they contain a geometry column. GeoPackage source file paths are always treated as vector data sources, and only one layer will be read from the source and written to the target. If you need to read raster data from a GeoPackage first create a SpatRaster from the layer of interest (see gpkg_rast()) before passing to gpkg_write(). If you need to read multiple layers from any multi-layer source read them individually into suitable objects. For a source GeoPackage containing multiple layers you can use gpkg_read() (returns a geopackage object) or gpkg_tables() (returns a list object).