ManageFarms | R Documentation |
R6 class that takes a database connection object, path to the folder with the farm boundaries, and a list with farm information to upload. Uploads boundaries to the database. Adds a unique ID field for each farm that is used for internal relationships. If a farm is already present in the database, it's information will be updated. This follows the ManageDB interface and includes a setup and execute method that is called from the ManageDB class.
dbCon
Database connection object connected to an OFPE formatted database, see DBCon class.
farm_info
List of farms to update, with each element a list with a 'farm_name' field for the name of the farm, a 'farm_shp_name' field with the name of the shapefile with the farm boundary, and a field called 'farmer_name' with the name of the farmer who own the farm.
farm_path
File path to the location of farm boundary shapefiles.
farms
List with data prepared for upload to the database. Contains shapefiles with a column indicating the associated farmer name.
new()
Create an ManageFarms object. The database connection and a list with farm information used to upload farm information to the database with the appropriate owner information. The farm_path argument indicates the file path in which to follow for the farm boundary shapefiles that are to be uploaded to the database. Instantiates the class for running the setup and execute methods.
ManageFarms$new(dbCon, action_item)
dbCon
Database connection object connected to an OFPE formatted database, see DBCon class.
action_item
List of inputs to the AddFarms method, from the list passed into the ManageDB class. This includes a list of farm information and a path to where the farm boundaries are stored.
A new initialized 'ManageFarms' object.
setup()
Prepares the farm data prior to uploading to the database. Imports shapefiles from the farm path and puts them into a list with the corresponding farmer to be uploaded to the database.
ManageFarms$setup()
None
No arguments needed because they are provided during class initialization.
Prepared R6 class for uploading farmer information.
execute()
Executes the upload of prepared farm information to the database in the 'all_farms' schema and the 'farms' table. If a farm boundary is already present with the same farm name and farmer that owns it, the entry in the database is replaced.
ManageFarms$execute()
None
No arguments needed because they are provided during class initialization.
Farm data uploaded into the 'all_farms.farms' table in the database.
.setupFarms()
Converts a list with information about the farms into a format ready for uploading to the database. Imports the shapefile using the path name in the list provided and adds a column for the farmer name. Converts to EPSG 4326 for storage.
ManageFarms$.setupFarms(farm_info, farm_path = NULL)
farm_info
List with information about the farm to upload.
farm_path
Path to the location of farm boundary shapefiles.
ESRI shapefile of farm boundary.
.uploadFarms()
Uploads a farm to the database. Takes the farm shapefile and identifies the coresponding farmeridx, adds it as a column, and then uploads to the 'all_farms.farms' table. Makes sure there is no conflict defined in the .buildTables method of the BuildDB class. A farmidx is automatically generated upon upload by PostgreSQL and the area of the farm is calculated and converted to acres. The dot indicates that this function would be private if not for documentations sake.
ManageFarms$.uploadFarms(farm, db)
farm
Farm shapefile for upload into 'all_farms.farmers'.
db
Database connection.
Farm upload into database.
clone()
The objects of this class are cloneable with this method.
ManageFarms$clone(deep = FALSE)
deep
Whether to make a deep clone.
DBCon
for database connection class,
ManageDB
for the class that calls this class to manage the database.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.