add_locations_into_ssdb: Add locations ("locations" table) to a SumavaDB-like...

add_locations_into_ssdbR Documentation

Add locations ("locations" table) to a SumavaDB-like spatiotemporal database

Description

Add locations ("locations" table) to a SumavaDB-like spatiotemporal database

Usage

add_locations_into_ssdb(
  conn,
  locations,
  new = FALSE,
  append = !new,
  sql_files = system.file("sql/create_or_replace_functions.sql", package = "SuSnowDB"),
  warn = TRUE,
  err = !warn,
  nn_locations = default_nn_locations(),
  ...
)

Arguments

conn

database (preferably PostgreSQL) connection. See output of dbConnect.

locations

locations, spatial object (or sf) . See output of sumava_snow_dataset

new

logical. If new==TRUE database tables are created or replaced. If new==FALSE tables are modidied according to append. Default is FALSE.

append

logical. If append==FALSE database tables are created or replaced. If append==FALSE data and metedata are appended as new rows of the database tables. Default is append=TRUE.

sql_files

file names containing database initialization SQL queries. They are used in case append==FALSE or new=TRUE.

warn

logical argument if the column names of locations are different from nn_locations functions displays a warning message. Default is TRUE.

err

logical argument if the column names of locations are different from nn_locations functions returns an error. Default is !warn.

nn_locations

names of the columns in the "locations" table. See the vignette.

...

further arguments (currently not used)

Examples

## Not run: 
library(RPostgreSQL) 
dbname <- "hydroclimatedb_testing00"
val <- sumava_snow_dataset()
conn = dbConnect(PostgreSQL(), dbname = dbname)
add_locations_into_ssdb(conn,val$locations,new=TRUE)
### Add weather station from MeteoTrentino network, Trentino, Italy 
val_smet <- meteotrentino_smet_dataset(smet_files=c("T0175","T0179"))
add_locations_into_ssdb(conn,val_smet$locations,append=TRUE)

dbDisconnect(conn)

conn = dbConnect(PostgreSQL(), dbname = dbname)
out <- st_read(conn,"locations")
dbDisconnect(conn)


## End(Not run)

ecor/SuSnowDB documentation built on Jan. 2, 2023, midnight