get_measurements_from_ssdb: Get measurements ("measurements" table) from a SumavaDB-like...

get_measurements_from_ssdbR Documentation

Get measurements ("measurements" table) from a SumavaDB-like spatiotemporal database

Description

Get measurements ("measurements" table) from a SumavaDB-like spatiotemporal database

Usage

get_measurements_from_ssdb(
  conn,
  table_name = "measurements",
  all = FALSE,
  variables_code0 = NULL,
  locations_code0 = NULL,
  returns.data.frame = FALSE,
  start_time = NA,
  end_time = NA,
  ...
)

Arguments

conn

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

table_name

name of the table . Default is "measurements"

all

logical. if it is TRUE all measurements (types) are extracted. Default is FALSE if something else is specified.

variables_code0

code of the types (variable_code0) of the measurements that are requested to be extracted.

locations_code0

code of the locations (location_code0) where to extract the measurements

returns.data.frame

logical. if it is TRUE function output is cated as a data frame. Default is FALSE.

start_time, end_time

start and end time instants of the time interval in which measurements are to be extrated.

...

further arguments for tbl

Examples

## Not run: 
library(RPostgreSQL) 
dbname <- "hydroclimatedb_testing00"
conn = dbConnect(PostgreSQL(), dbname = dbname)


### Add weather data from stations from MeteoTrentino network, Trentino, Italy 
val_smet <- meteotrentino_smet_dataset(smet_files=c("T0175","T0179"))
add_locations_into_ssdb(conn,val_smet$locations,new=TRUE)
add_measurement_types_into_ssdb(conn,val_smet$measurement_type)
add_measurements_into_ssdb(conn,val_smet$measurements)

dbDisconnect(conn)

conn = dbConnect(PostgreSQL(), dbname = dbname)
out <- get_measurements_from_ssdb(conn)
out <- get_measurements_from_ssdb(conn,locations_code0="IT-TN_T0179")
out <- get_measurements_from_ssdb(conn,locations_code0="IT-TN_T0179",
variables_code0=c("SMET_TA","SMET_PINT"))
out <- get_measurements_from_ssdb(conn,
variables_code0=c("SMET_TA","SMET_PINT"))

time_interval <- as.Date(c("2021-03-01","2021-03-31"))
out <- get_measurements_from_ssdb(conn,
variables_code0=c("SMET_TA","SMET_PINT"),
start_time=time_interval[1],end_time=time_interval[2])
dbDisconnect(conn)


## End(Not run)

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