fetchAggStratDat: Fetch data for stratification

View source: R/rxFuns.R

fetchAggStratDatR Documentation

Fetch data for stratification

Description

This function fetches user specified data from an OFPE database. This function is for gathering stratified data from an aggregated table. A much simpler query can easily be written for raw data using the original filename. This function can be executed with the 'strat_var' variable set to NULL (default) to return all columns in the database. If 'strat_var' is provided, the 'x', 'y', 'cell_id', and 'field' columns will be returned, as well as the column corresponding to the 'strat_var'.

This function queries the aggregated database sequentially for different combinations of the 'grid' and 'datused' parameters. The aggregated table is specified by the 'table_var', and the schema name is created from the 'farmername' parameter. This table is queried for data with the user specified 'field' for the stratification data, 'year' of the stratification data, and the size of the grid used for cleaning and aggregation ('grid_size'). The user must also specify the connection to an OFPE formatted database.

Usage

fetchAggStratDat(
  table_var,
  strat_var = NULL,
  field,
  year,
  farmername,
  grid_size,
  db
)

Arguments

table_var

The name of the table in the farmer's aggregated schema ('_a') that contains the stratification data.

strat_var

Optional, default is NULL. Leave NULL to return all columns in the specified data. Otherwise provide the column name with the variable for stratification. This returns the selected column and 'x', 'y', 'cell_id', and 'field'.

field

Field that the stratification data is from.

year

The year to gather the stratification for.

farmername

The farmer that manages the field the stratification data is from.

grid_size

The size of the grid (in meters) that was used to clean and aggregate the data on. Even if observed data points are used they were cleaned using a specified grid size, which is what is passed in here.

db

Connection to an OFPE formatted database.

Value

A data frame with either all colums or the 'x', 'y', 'cell_id', 'field', and strat_var columns.


paulhegedus/OFPE documentation built on Nov. 23, 2022, 5:09 a.m.