Title: | Workflow for Geographic Data |
---|---|
Description: | Streamlines geographic data transformation, storage and publication, simplifying data preparation and enhancing interoperability across formats and platforms. |
Authors: | Jose Samos [aut, cre] , Universidad de Granada [cph] |
Maintainer: | Jose Samos <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2024-12-23 13:43:04 UTC |
Source: | CRAN |
Aggregates all raster files ('.tif' or '.jp2') in a specified folder by the given factor and saves the resulting files in an output folder.
aggregate_rasters(dir, out_dir, factor = 2)
aggregate_rasters(dir, out_dir, factor = 2)
dir |
A string specifying the input folder containing raster files. |
out_dir |
A string specifying the output folder where the aggregated rasters will be saved. |
factor |
An integer specifying the aggregation factor (default is 2). |
If the output folder does not exist, it creates it.
A character vector with the paths to the processed raster files.
Other transform raster functions:
compose_raster()
temp_dir <- tempdir() input_dir <- system.file("extdata", "mdt", package = "sigugr") result_files <- aggregate_rasters(input_dir, temp_dir, factor = 4)
temp_dir <- tempdir() input_dir <- system.file("extdata", "mdt", package = "sigugr") result_files <- aggregate_rasters(input_dir, temp_dir, factor = 4)
Clips a vector layer using a polygon layer. It handles CRS transformations automatically if necessary, ensuring the output is in the same CRS as the input polygon.
clip_layer(vector, polygon)
clip_layer(vector, polygon)
vector |
An 'sf' object representing the vector layer to be clipped. |
polygon |
An 'sf' object representing the polygon layer used for clipping. |
An 'sf' object containing the features of the input 'vector' that intersect with the 'polygon'. The output will be in the CRS of the 'polygon', and it will retain all attributes of the input 'vector'.
Other clip functions:
clip_multipoligon()
,
clip_raster()
,
generate_bbox()
gpkg_path <- system.file("extdata", "clc.gpkg", package = "clc") clc <- sf::st_read(gpkg_path, layer = "clc", quiet = TRUE) lanjaron <- sf::st_read(gpkg_path, layer = "lanjaron", quiet = TRUE) clc_clipped <- clip_layer(clc, lanjaron)
gpkg_path <- system.file("extdata", "clc.gpkg", package = "clc") clc <- sf::st_read(gpkg_path, layer = "clc", quiet = TRUE) lanjaron <- sf::st_read(gpkg_path, layer = "lanjaron", quiet = TRUE) clc_clipped <- clip_layer(clc, lanjaron)
Clips a 'MULTIPOLYGON' vector layer using a polygon layer, handling specific issues that might arise with geometries encoded incorrectly or containing unknown WKB types. It serves as a fallback when the 'clip_layer' function fails due to errors like 'ParseException: Unknown WKB type 12', which is associated with *MULTIPOLYGON* types.
clip_multipoligon(vector, polygon)
clip_multipoligon(vector, polygon)
vector |
A 'sf' multipolygon vector layer to be clipped. |
polygon |
A 'sf' polygon layer used as the clipping geometry. |
The function ensures that the input layer is correctly encoded as 'MULTIPOLYGON' and uses GDAL utilities for re-encoding if necessary. The output is projected to the CRS of the clipping polygon.
This solution is inspired by a discussion on handling WKB type errors in R: <https://gis.stackexchange.com/questions/389814/r-st-centroid-geos-error-unknown-wkb-type-12>.
A 'sf' vector layer with the clipped geometries.
Other clip functions:
clip_layer()
,
clip_raster()
,
generate_bbox()
gpkg_path <- system.file("extdata", "clc.gpkg", package = "clc") clc <- sf::st_read(gpkg_path, layer = "clc", quiet = TRUE) lanjaron <- sf::st_read(gpkg_path, layer = "lanjaron", quiet = TRUE) clc_clipped <- clip_multipoligon(clc, lanjaron)
gpkg_path <- system.file("extdata", "clc.gpkg", package = "clc") clc <- sf::st_read(gpkg_path, layer = "clc", quiet = TRUE) lanjaron <- sf::st_read(gpkg_path, layer = "lanjaron", quiet = TRUE) clc_clipped <- clip_multipoligon(clc, lanjaron)
Clips a raster using a polygon, preserving the coordinate reference system (CRS) of the raster.
clip_raster(raster, polygon, keep_crs = TRUE)
clip_raster(raster, polygon, keep_crs = TRUE)
raster |
A 'terra' raster to be clipped. |
polygon |
A 'sf' polygon layer used for clipping. |
keep_crs |
Logical. If 'TRUE', retains the original CRS of the raster. If 'FALSE', transforms the raster to the polygon CRS. Default is 'TRUE'. |
A 'terra' raster clipped to the extent of the polygon.
Other clip functions:
clip_layer()
,
clip_multipoligon()
,
generate_bbox()
source_gpkg <- system.file("extdata", "sigugr.gpkg", package = "sigugr") p <-sf::st_read(source_gpkg, layer = 'lanjaron', quiet = TRUE) source_tif <- system.file("extdata", "sat.tif", package = "sigugr") r <- terra::rast(source_tif) result <- clip_raster(r, p)
source_gpkg <- system.file("extdata", "sigugr.gpkg", package = "sigugr") p <-sf::st_read(source_gpkg, layer = 'lanjaron', quiet = TRUE) source_tif <- system.file("extdata", "sat.tif", package = "sigugr") r <- terra::rast(source_tif) result <- clip_raster(r, p)
Combines multiple raster files into a single virtual raster layer (VRT). It accepts one or more folder names containing raster files and creates a virtual raster file. If no output file name is provided, a temporary file is used.
compose_raster(dir, out_file = NULL)
compose_raster(dir, out_file = NULL)
dir |
A string or vector of strings representing folder names containing raster files. |
out_file |
A string specifying the output file name (without extension). If 'NULL', a temporary file is used. |
A 'SpatRaster' object from the 'terra' package.
Other transform raster functions:
aggregate_rasters()
input_dir <- system.file("extdata", "mdt", package = "sigugr") r <- compose_raster(input_dir)
input_dir <- system.file("extdata", "mdt", package = "sigugr") r <- compose_raster(input_dir)
Copies layer styles from a source (GeoPackage or PostGIS database) to a destination (GeoPackage or PostGIS database). The source and destination can be specified flexibly, and the function supports copying styles to multiple layers in the destination.
copy_styles( from, from_layer = NULL, to, database = NULL, schema = "public", to_layers = NULL )
copy_styles( from, from_layer = NULL, to, database = NULL, schema = "public", to_layers = NULL )
from |
A data source for the input style. This can be: - A string representing the path to a GeoPackage file. - A 'DBI' database connection object to a PostGIS database, created using [RPostgres::dbConnect()]. |
from_layer |
Character (optional). Name of the layer in the source to copy the style from. If not provided, the function will use the first layer in the source with a defined style. |
to |
A data destination for the output styles. This can be: - A string representing the path to a GeoPackage file. - A 'DBI' database connection object to a PostGIS database, created using [RPostgres::dbConnect()]. |
database |
Character (optional). Name of the destination PostGIS database (required if the destination is a PostGIS connection object). |
schema |
Character. Schema in the destination PostGIS database where the styles will be applied. Default is "public". |
to_layers |
Character vector (optional). Names of the layers in the destination where the style will be applied. If not provided, the style will be applied to all layers in the destination. |
The updated 'layer_styles' table, returned invisibly.
Other style functions:
get_layer_categories()
# Ex1: source_gpkg <- system.file("extdata", "clc.gpkg", package = "clc") layer_data <- sf::st_read(source_gpkg, layer = "clc", quiet = TRUE) dest_gpkg <- tempfile(fileext = ".gpkg") sf::st_write(layer_data, dest_gpkg, layer = "clc", quiet = TRUE) copy_styles(from = source_gpkg, to = dest_gpkg) ## Not run: # Ex2: source_gpkg <- system.file("extdata", "clc.gpkg", package = "clc") conn <- DBI::dbConnect( RPostgres::Postgres(), dbname = "mydb", host = "localhost", user = "user", password = "password" ) copy_styles( from = source_gpkg, to = conn, database = "mydb", schema = "public", to_layers = c("layer1", "layer2"), ) DBI::dbDisconnect(conn) ## End(Not run)
# Ex1: source_gpkg <- system.file("extdata", "clc.gpkg", package = "clc") layer_data <- sf::st_read(source_gpkg, layer = "clc", quiet = TRUE) dest_gpkg <- tempfile(fileext = ".gpkg") sf::st_write(layer_data, dest_gpkg, layer = "clc", quiet = TRUE) copy_styles(from = source_gpkg, to = dest_gpkg) ## Not run: # Ex2: source_gpkg <- system.file("extdata", "clc.gpkg", package = "clc") conn <- DBI::dbConnect( RPostgres::Postgres(), dbname = "mydb", host = "localhost", user = "user", password = "password" ) copy_styles( from = source_gpkg, to = conn, database = "mydb", schema = "public", to_layers = c("layer1", "layer2"), ) DBI::dbDisconnect(conn) ## End(Not run)
Takes an 'sf' object or a 'terra::SpatRaster' as input and returns a new 'sf' object representing the bounding box (minimum bounding rectangle) of the input layer.
generate_bbox(layer)
generate_bbox(layer)
layer |
An 'sf' object or a 'terra::SpatRaster' object. |
An 'sf' object representing the bounding box of the input layer.
Other clip functions:
clip_layer()
,
clip_multipoligon()
,
clip_raster()
# Example with a vector layer source_gpkg <- system.file("extdata/sigugr.gpkg", package = "sigugr") lanjaron <- sf::st_read(source_gpkg, layer = "lanjaron", quiet = TRUE) bbox_vector <- generate_bbox(lanjaron) # Example with a raster layer raster_file <- system.file("extdata/sat.tif", package = "sigugr") raster <- terra::rast(raster_file) bbox_raster <- generate_bbox(raster)
# Example with a vector layer source_gpkg <- system.file("extdata/sigugr.gpkg", package = "sigugr") lanjaron <- sf::st_read(source_gpkg, layer = "lanjaron", quiet = TRUE) bbox_vector <- generate_bbox(lanjaron) # Example with a raster layer raster_file <- system.file("extdata/sat.tif", package = "sigugr") raster <- terra::rast(raster_file) bbox_raster <- generate_bbox(raster)
This S3 class represents a connection to a GeoServer instance. It stores the connection details, including the base URL, user credentials, and the default workspace.
geoserver(url, user, password, workspace)
geoserver(url, user, password, workspace)
url |
A character string specifying the base URL of the GeoServer instance (e.g., '"http://localhost:8080/geoserver"'). |
user |
A character string representing the GeoServer username with the required permissions. |
password |
A character string representing the password for the specified user. |
workspace |
A character string specifying the default workspace to use in GeoServer operations. |
An object of class 'geoserver' or NULL if an error occurred.
Other publish to GeoServer:
publish_bands()
,
publish_layer()
,
publish_layer_set()
,
publish_raster()
,
register_datastore_postgis()
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) ## End(Not run)
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) ## End(Not run)
Extracts the categories (IDs, descriptions, and colors) from the first style definition stored in a GeoPackage or PostGIS database. The extracted categories are filtered to include only those present in the raster values.
get_layer_categories(from, r_clc = NULL)
get_layer_categories(from, r_clc = NULL)
from |
A data origin. This can be: - A string representing the path to a GeoPackage file. - A 'DBI' database connection object to a PostGIS database, created using [RPostgres::dbConnect()]. |
r_clc |
A 'terra' raster object containing the raster values to filter the categories. If NULL, returns all categories. |
The function retrieves the style definitions from the 'layer_styles' table in the provided GeoPackage or PostGIS database. It filters the categories to include only those whose IDs match the unique values present in the raster.
It is useful for associating raster values with their corresponding descriptions and colors, typically for visualization or analysis tasks.
A data frame containing the filtered categories with the following columns: - 'id': The category ID (integer). - 'description': The description of the category (character). - 'color': The color associated with the category in hexadecimal format (character).
Other style functions:
copy_styles()
gpkg_path <- system.file("extdata", "clc.gpkg", package = "clc") categories <- get_layer_categories(from = gpkg_path)
gpkg_path <- system.file("extdata", "clc.gpkg", package = "clc") categories <- get_layer_categories(from = gpkg_path)
Publishes bands of a multi-band GeoTIFF raster file as separate coverages in a specified workspace on a GeoServer instance.
publish_bands(gso, raster, prefix, postfix, bands) ## S3 method for class 'geoserver' publish_bands(gso, raster, prefix = NULL, postfix = NULL, bands = NULL)
publish_bands(gso, raster, prefix, postfix, bands) ## S3 method for class 'geoserver' publish_bands(gso, raster, prefix = NULL, postfix = NULL, bands = NULL)
gso |
An object of class 'geoserver' containing GeoServer connection details. |
raster |
A character string specifying the file path to the GeoTIFF raster file to be uploaded. |
prefix |
A string to prepend to each layer name. Default is 'NULL'. |
postfix |
A string to append to each layer name. Default is 'NULL'. |
bands |
A named integer vector, index of the bands to publish with layer names. If it is 'NULL', which is the default value, all bands are published using the band name as the layer name. If unnamed indices are provided, the band name is also used as the layer name. |
An integer:
0
if the operation was successful or if the layer already exists.
1
if an error occurred.
Other publish to GeoServer:
geoserver()
,
publish_layer()
,
publish_layer_set()
,
publish_raster()
,
register_datastore_postgis()
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) source_tif <- system.file("extdata/sat.tif", package = "sigugr") gso |> publish_bands(source_tif) ## End(Not run)
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) source_tif <- system.file("extdata/sat.tif", package = "sigugr") gso |> publish_bands(source_tif) ## End(Not run)
Publishes a vector layer to GeoServer. The layer source must have previously been defined as a GeoSever datastore.
publish_layer(gso, layer, title) ## S3 method for class 'geoserver' publish_layer(gso, layer, title = NULL)
publish_layer(gso, layer, title) ## S3 method for class 'geoserver' publish_layer(gso, layer, title = NULL)
gso |
An object of class 'geoserver' containing GeoServer connection details. |
layer |
A string, the name of the layer to publish. |
title |
A string, an optional title for the layer. Defaults to the layer name if not provided. |
Prints an appropriate message indicating success or failure.
An integer:
0
if the operation was successful or if the layer already exists.
1
if an error occurred.
Other publish to GeoServer:
geoserver()
,
publish_bands()
,
publish_layer_set()
,
publish_raster()
,
register_datastore_postgis()
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) gso <- gso |> register_datastore_postgis( "sigugr-postgis", db_name = 'sigugr_example', host = 'localhost', port = 5432, db_user = 'user', db_password = 'password', schema = "public" ) gso |> publish_layer(layer = 'sigugr_layer') ## End(Not run)
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) gso <- gso |> register_datastore_postgis( "sigugr-postgis", db_name = 'sigugr_example', host = 'localhost', port = 5432, db_user = 'user', db_password = 'password', schema = "public" ) gso |> publish_layer(layer = 'sigugr_layer') ## End(Not run)
Publishes a vector layer set to GeoServer. The layer source must have previously been defined as a GeoSever datastore.
publish_layer_set(gso, source, layers) ## S3 method for class 'geoserver' publish_layer_set(gso, source, layers = NULL)
publish_layer_set(gso, source, layers) ## S3 method for class 'geoserver' publish_layer_set(gso, source, layers = NULL)
gso |
An object of class 'geoserver' containing GeoServer connection details. |
source |
A valid connection to a PostGIS database ('RPostgres' connection object). |
layers |
An optional character vector of layer names to check and publish. If 'NULL' (default), all vector geometry layers in the source will be published. |
Iterates over a set of layers in a source database, checking whether each layer contains vector geometry. If the layer meets the criteria, it is published. If the 'layers' parameter is 'NULL', the function will publish all layers with vector geometry in the source.
Prints an appropriate messages indicating success or failure.
An integer:
0
if the operation was successful for all layers.
1
if an error occurred.
Other publish to GeoServer:
geoserver()
,
publish_bands()
,
publish_layer()
,
publish_raster()
,
register_datastore_postgis()
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) gso <- gso |> register_datastore_postgis( "sigugr-postgis", db_name = 'sigugr_example', host = 'localhost', port = 5432, db_user = 'user', db_password = 'password', schema = "public" ) source <- RPostgres::dbConnect( RPostgres::Postgres(), dbname = 'mydb', host = 'localhost', port = '5432', user = 'user', password = 'password' ) gso |> publish_layer_set(source) ## End(Not run)
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) gso <- gso |> register_datastore_postgis( "sigugr-postgis", db_name = 'sigugr_example', host = 'localhost', port = 5432, db_user = 'user', db_password = 'password', schema = "public" ) source <- RPostgres::dbConnect( RPostgres::Postgres(), dbname = 'mydb', host = 'localhost', port = '5432', user = 'user', password = 'password' ) gso |> publish_layer_set(source) ## End(Not run)
Publishes a GeoTIFF raster file to a workspace and data store on a GeoServer instance.
publish_raster(gso, raster, layer) ## S3 method for class 'geoserver' publish_raster(gso, raster, layer = NULL)
publish_raster(gso, raster, layer) ## S3 method for class 'geoserver' publish_raster(gso, raster, layer = NULL)
gso |
An object of class 'geoserver' containing GeoServer connection details. |
raster |
A character string specifying the file path to the GeoTIFF raster file to be uploaded. |
layer |
A string, the name of the layer to publish. If it is 'NULL', which is the default value, the layer name is derived from the filename. |
An integer:
0
if the operation was successful or if the layer already exists.
1
if an error occurred.
Other publish to GeoServer:
geoserver()
,
publish_bands()
,
publish_layer()
,
publish_layer_set()
,
register_datastore_postgis()
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) source_tif <- system.file("extdata/sat.tif", package = "sigugr") gso |> publish_raster(source_tif, "sat-tiff") ## End(Not run)
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) source_tif <- system.file("extdata/sat.tif", package = "sigugr") gso |> publish_raster(source_tif, "sat-tiff") ## End(Not run)
Registers a PostGIS database as a 'datastore' in a specified GeoServer workspace.
register_datastore_postgis( gso, datastore, db_name, host, port, db_user, db_password, schema ) ## S3 method for class 'geoserver' register_datastore_postgis( gso, datastore, db_name, host, port = 5432, db_user, db_password, schema = "public" )
register_datastore_postgis( gso, datastore, db_name, host, port, db_user, db_password, schema ) ## S3 method for class 'geoserver' register_datastore_postgis( gso, datastore, db_name, host, port = 5432, db_user, db_password, schema = "public" )
gso |
An object of class 'geoserver' containing GeoServer connection details. |
datastore |
A character string. The name of the datastore to be created. |
db_name |
A character string. The name of the PostGIS database. |
host |
A character string. The database host. |
port |
An integer. The database port (default: 5432). |
db_user |
A character string. The database username. |
db_password |
A character string. The database password. |
schema |
A character string. The database schema (default: "public"). |
If the 'datastore' has already been registered previously, there is no need to specify the database connection. For subsequent operations, that 'datastore' will be used.
In any case, prints an appropriate message.
An object of class 'geoserver' or NULL if an error occurred.
Other publish to GeoServer:
geoserver()
,
publish_bands()
,
publish_layer()
,
publish_layer_set()
,
publish_raster()
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) gso <- gso |> register_datastore_postgis( "sigugr-postgis", db_name = 'sigugr_example', host = 'localhost', port = 5432, db_user = 'user', db_password = 'password', schema = "public" ) ## End(Not run)
## Not run: gso <- geoserver( url = "http://localhost:8080/geoserver", user = "admin", password = "geoserver", workspace = "sigugr_test" ) gso <- gso |> register_datastore_postgis( "sigugr-postgis", db_name = 'sigugr_example', host = 'localhost', port = 5432, db_user = 'user', db_password = 'password', schema = "public" ) ## End(Not run)
Stores each band of a raster to a specified schema in a PostGIS database. Each band is written as a separate table in the database.
store_bands( raster, conn, schema = "public", prefix = NULL, postfix = NULL, bands = NULL )
store_bands( raster, conn, schema = "public", prefix = NULL, postfix = NULL, bands = NULL )
raster |
A character string specifying the file path to the GeoTIFF file containing the raster bands to be stored. |
conn |
A database connection object to a PostGIS database (e.g., from 'RPostgres::dbConnect'). |
schema |
A string specifying the schema in the PostGIS database where the raster layers will be stored. Default is '"public"'. |
prefix |
A string to prepend to each layer name. Default is 'NULL'. |
postfix |
A string to append to each layer name. Default is 'NULL'. |
bands |
A named integer vector, index of the bands to store with layer names. If it is 'NULL', which is the default value, all bands are stored using the band name as the layer name. If unnamed indices are provided, the band name is also used as the layer name. |
Transforms the table name according to the Snake Case convention.
Invisibly returns a character vector of the names of the tables written to PostGIS.
Other write to PostGIS:
store_layers()
,
store_raster()
## Not run: conn <- DBI::dbConnect( RPostgres::Postgres(), dbname = "mydb", host = "localhost", user = "user", password = "password" ) sr <- terra::rast(nrows = 10, ncols = 10, nlyrs = 3, vals = runif(300)) sr_file <- tempfile(fileext = ".tif") terra::writeRaster(sr, sr_file, filetype = "GTiff", overwrite = TRUE) tables <- store_bands(sr_file, conn, schema = "geodata", prefix = "example_", postfix = "_raster") DBI::dbDisconnect(conn) ## End(Not run)
## Not run: conn <- DBI::dbConnect( RPostgres::Postgres(), dbname = "mydb", host = "localhost", user = "user", password = "password" ) sr <- terra::rast(nrows = 10, ncols = 10, nlyrs = 3, vals = runif(300)) sr_file <- tempfile(fileext = ".tif") terra::writeRaster(sr, sr_file, filetype = "GTiff", overwrite = TRUE) tables <- store_bands(sr_file, conn, schema = "geodata", prefix = "example_", postfix = "_raster") DBI::dbDisconnect(conn) ## End(Not run)
Transfers vector layers with valid geometries from a GeoPackage file to a specified PostGIS database schema. Optionally allows setting a custom geometry column name, adding prefixes or postfixes to the table names, and renaming the layer fields to follow the Snake Case convention.
store_layers( gpkg, conn, schema = "public", prefix = NULL, postfix = NULL, layers = NULL, geom_colum = "geom", snake_case_fields = TRUE )
store_layers( gpkg, conn, schema = "public", prefix = NULL, postfix = NULL, layers = NULL, geom_colum = "geom", snake_case_fields = TRUE )
gpkg |
A string, the path to the GeoPackage file. |
conn |
A PostGIS database connection object created with [RPostgres::dbConnect()]. |
schema |
A string, the schema in PostGIS where layers will be stored. Default is '"public"'. |
prefix |
A string, an optional prefix to add to the table names in PostGIS. Default is 'NULL'. |
postfix |
A string, an optional postfix to add to the table names in PostGIS. Default is 'NULL'. |
layers |
A string vector, the name of the layers to transfer. If NULL, all vector layers are transferred. |
geom_colum |
A string, the name of the geometry column to set. Default is '"geom"'. |
snake_case_fields |
A logical, whether to convert field names to Snake Case. Default is 'TRUE'. |
Invisibly returns a character vector of the names of the tables written to PostGIS.
Other write to PostGIS:
store_bands()
,
store_raster()
## Not run: source_gpkg <- system.file("extdata", "sigugr.gpkg", package = "sigugr") conn <- DBI::dbConnect( RPostgres::Postgres(), dbname = "mydb", host = "localhost", user = "user", password = "password" ) store_layers( source_gpkg, conn, prefix = "pre_", postfix = "_post" ) DBI::dbDisconnect(conn) ## End(Not run)
## Not run: source_gpkg <- system.file("extdata", "sigugr.gpkg", package = "sigugr") conn <- DBI::dbConnect( RPostgres::Postgres(), dbname = "mydb", host = "localhost", user = "user", password = "password" ) store_layers( source_gpkg, conn, prefix = "pre_", postfix = "_post" ) DBI::dbDisconnect(conn) ## End(Not run)
Stores all bands of a raster to a specified schema in a PostGIS database. All bands are written in the same table in the database.
store_raster(raster, conn, schema = "public", table_name = NULL)
store_raster(raster, conn, schema = "public", table_name = NULL)
raster |
A character string specifying the file path to the GeoTIFF raster file to be stored. |
conn |
A database connection object to a PostGIS database (e.g., from 'RPostgres::dbConnect'). |
schema |
A string specifying the schema in the PostGIS database where the raster layers will be stored. Default is '"public"'. |
table_name |
A string, table name. If it is 'NULL', which is the default value, the layer name is derived from the filename. |
Transforms the table name according to the Snake Case convention.
Invisibly returns a character vector of the names of the tables written to PostGIS.
Other write to PostGIS:
store_bands()
,
store_layers()
## Not run: source_tif <- system.file("extdata", "mdt.tif", package = "clc") conn <- DBI::dbConnect( RPostgres::Postgres(), dbname = "mydb", host = "localhost", user = "user", password = "password" ) tables <- store_raster(source_tif, conn, table_name = "mdt") DBI::dbDisconnect(conn) ## End(Not run)
## Not run: source_tif <- system.file("extdata", "mdt.tif", package = "clc") conn <- DBI::dbConnect( RPostgres::Postgres(), dbname = "mydb", host = "localhost", user = "user", password = "password" ) tables <- store_raster(source_tif, conn, table_name = "mdt") DBI::dbDisconnect(conn) ## End(Not run)