ImportOF: R6 Class for importing on-farm data to an OFPE database

ImportOFR Documentation

R6 Class for importing on-farm data to an OFPE database

Description

R6 class for for importing data collected on-farms data into an OFPE formatted database.

Public fields

dbCon

Database connection object connected to an OFPE formatted database, see DBCon class.

dat_path

Path to the folder that contains the data for upload into the OFPE database.

file_names

Names of the files in the data folder.

status

Data frame with a status update on the completion of each file's data import.

farmers

The 'farmers' table from the 'all_farms' schema of an OFPE formatted database.

farms

The 'farms' table from the 'all_farms' schema of an OFPE formatted database.

fields

The 'fields' table from the 'all_farms' schema of an OFPE formatted database.

Methods

Public methods


Method new()

Create a database importer object.

Usage
ImportOF$new(dbCon, dat_path)
Arguments
dbCon

Database connection object connected to an OFPE formatted database, see DBCon class.

dat_path

Path to the folder that contains the data for upload into the OFPE database.

Returns

A new 'ImportOF' object.


Method executeUpload()

On-farm data import execution.

Usage
ImportOF$executeUpload()
Arguments
None

No arguments needed because of class instantiation.

Returns

See 'status' object.


Method .uploadData()

Uploads data to an OFPE formatted database following a chain of methods and returning the status of the upload. The dot indicates that this function would be private if not for documentations sake.

Usage
ImportOF$.uploadData(name)
Arguments
name

Name of the data file to upload to the database.

Returns

See 'status' object.


Method .impDat()

Imports data for uploading to an OFPE database. If data is a shapefile imported directly using 'sf' package, otherwise brings in data as .csv. The dot indicates that this function would be private if not for documentations sake.

Usage
ImportOF$.impDat(name)
Arguments
name

Name of the data file to upload to the database.

Returns

Imported data.


Method .makeSptl()

Makes data that was imported for uploading into spatial data. This only applies to non-shapefiles, as they are already spatial. This is for the .csv protein or SSURGO data that is imported. The dot indicates that this function would be private if not for documentations sake.

Usage
ImportOF$.makeSptl(FILE, name)
Arguments
FILE

The imported data from the .impDat method.

name

The filename for the data imported from the .impDat method.

Returns

Data in spatial format.


Method .oldDatClean()

Cleans up any column names that might mess with new ones that are created in the data workflow. This is mainly to prevent issues when using data from Phil's database. The dot indicates that this would be private if not for documentations sake.

Usage
ImportOF$.oldDatClean(FILE)
Arguments
FILE

The imported data for upload.

Returns

Data without old columns.


Method .findInfo()

Identifies distinguishing features of the data, such as a field name if present, the corresponding farmer, and the year the data is collected. The dot indicates that this would be private if not for documentations sake.

Usage
ImportOF$.findInfo(FILE, name)
Arguments
FILE

The imported data for upload.

name

The name of the file for upload.

Returns

Data without old columns.


Method .fixCols()

Goes through each file and replaces any column names with more palatable formats such as lower case and without any special characters. The dot indicates that this would be private if not for documentations sake.

Usage
ImportOF$.fixCols(FILE)
Arguments
FILE

The imported data for upload.

Returns

Data with cleaned up column names.


Method .uploadFun()

Function for uploading each file to the appropriate section of the database. This function identifies the data type and uses the information identified in the data to organize and upload the data. The dot indicates that this would be private if not for documentations sake.

Usage
ImportOF$.uploadFun(FILE, name, db)
Arguments
FILE

The imported data for upload.

name

The name of the file for upload.

db

Connection to an OFPE database.

Returns

Data uploaded to the database


Method clone()

The objects of this class are cloneable with this method.

Usage
ImportOF$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

DBCon for the database connection class, and ImportGEE for the associated Google Earth Engine data import class in the data import step.


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