Write data to a GeoPackage
gpkg_write(
x,
destfile,
table_name = NULL,
datatype = "FLT4S",
append = FALSE,
overwrite = FALSE,
NoData = NULL,
gdal_options = NULL,
...
)
Vector of source file path(s), or a list containing one or more SpatRaster, SpatRasterCollection, or SpatVectorProxy objects.
Character. Path to output GeoPackage
Character. Default NULL
name is derived from source file.
Required if x
is a data.frame.
Data type. Defaults to "FLT4S"
for GeoTIFF files, "INT2U"
otherwise. See documentation for terra::writeRaster()
.
Append to existing data source? Default: FALSE
. Setting
append=TRUE
overrides overwrite=TRUE
Overwrite existing data source? Default FALSE
.
Value to use as GDAL NoData
Value
Additional gdal_options
, passed to
terra::writeRaster()
Additional arguments are passed as GeoPackage "creation options." See Details.
Logical. TRUE
on successful write of at least one grid.
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).