Title: | Precision Agriculture Data Analysis |
---|---|
Description: | Precision agriculture spatial data depuration and homogeneous zones (management zone) delineation. The package includes functions that performs protocols for data cleaning management zone delineation and zone comparison; protocols are described in Paccioretti et al., (2020) <doi:10.1016/j.compag.2020.105556>. |
Authors: | Pablo Paccioretti [aut, cre, cph], Mariano Córdoba [aut], Franca Giannini-Kurina [aut], Mónica Balzarini [aut] |
Maintainer: | Pablo Paccioretti <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2024-11-08 05:30:02 UTC |
Source: | https://github.com/ppaccioretti/paar |
A dataset containing Barley grain yield using calibrated commercial yield monitors mounted on combines equipped with DGPS.
barley
barley
A data frame with 7395 rows and 3 variables:
X coordinate, in meters
Y coordinate, in meters
grain yield, in ton per hectare
Coordinate reference system is "WGS 84 / UTM zone 20S", epsg:32720
Bind outlier condition to an object.
## S3 method for class 'paar' cbind(..., deparse.level = 1)
## S3 method for class 'paar' cbind(..., deparse.level = 1)
... |
objects to bind. |
deparse.level |
integer controlling the construction of labels in
the case of non-matrix-like arguments (for the default method): |
cbind
called with m.
Compare spatial zone means
compare_zone( data, variable, zonesCol, alpha = 0.05, join = sf::st_nearest_feature, returnLSD = FALSE, grid_dim )
compare_zone( data, variable, zonesCol, alpha = 0.05, join = sf::st_nearest_feature, returnLSD = FALSE, grid_dim )
data |
|
variable |
|
zonesCol |
|
alpha |
|
join |
function to use for st_join if variable is |
returnLSD |
|
grid_dim |
|
list
with differences and descriptive_stat
Paccioretti, P., Córdoba, M., & Balzarini, M. (2020). FastMapping: Software to create field maps and identify management zones in precision agriculture. Computers and Electronics in Agriculture, 175, 105556 https://doi.org/10.1016/j.compag.2020.105556.
library(sf) data(wheat, package = "paar") ##Convert to an sf object wheat <- sf::st_as_sf(wheat, coords = c("x", "y"), crs = 32720) clusters <- paar::kmspc( wheat, variables = c('CE30', 'CE90', 'Elev', 'Pe', 'Tg'), number_cluster = 3:4 ) data_clusters <- cbind(wheat, clusters$cluster) compare_zone(data_clusters, "Elev", "Cluster_3")
library(sf) data(wheat, package = "paar") ##Convert to an sf object wheat <- sf::st_as_sf(wheat, coords = c("x", "y"), crs = 32720) clusters <- paar::kmspc( wheat, variables = c('CE30', 'CE90', 'Elev', 'Pe', 'Tg'), number_cluster = 3:4 ) data_clusters <- cbind(wheat, clusters$cluster) compare_zone(data_clusters, "Elev", "Cluster_3")
Data can be filtered by null, edge values, global outliers and spatial outliers or local defective observations. Default values are optimized for precision agricultural data.
depurate( x, y, toremove = c("edges", "outlier", "inlier"), crs = NULL, buffer = -10, ylimitmax = NA, ylimitmin = 0, sdout = 3, ldist = 0, udist = 40, criteria = c("LM", "MP"), zero.policy = NULL, poly_border = NULL )
depurate( x, y, toremove = c("edges", "outlier", "inlier"), crs = NULL, buffer = -10, ylimitmax = NA, ylimitmin = 0, sdout = 3, ldist = 0, udist = 40, criteria = c("LM", "MP"), zero.policy = NULL, poly_border = NULL )
x |
an |
y |
|
toremove |
|
crs |
coordinate reference system: integer with the EPSG code,
or character with proj4string to convert coordinates if |
buffer |
|
ylimitmax |
|
ylimitmin |
|
sdout |
|
ldist |
|
udist |
|
criteria |
|
zero.policy |
default NULL, use global option value; if FALSE stop with error for any empty neighbors sets, if TRUE permit the weights list to be formed with zero-length weights vectors |
poly_border |
|
Possible values for toremove
are one or more elements of:
All data points for a distance of buffer
m from data
edges are deleted.
Values that are outside the mean±sdout
are removed
Local Moran index of spatial autocorrelation is calculated for each datum as a tool to identify inliers
an object of class paar
with two elements:
sf
object with the data after the removal
process
character
vector with the condition of each
observation
Vega, A., Córdoba, M., Castro-Franco, M. et al. Protocol for automating error removal from yield maps. Precision Agric 20, 1030–1044 (2019). https://doi.org/10.1007/s11119-018-09632-8
library(sf) data(barley, package = 'paar') #Convert to an sf object barley <- st_as_sf(barley, coords = c("X", "Y"), crs = 32720) depurated <- depurate(barley, "Yield") # Summary of depurated data summary(depurated) # Keep only depurate data depurated_data <- depurated$depurated_data # Combine the condition for all data all_data_condition <- cbind(depurated, barley)
library(sf) data(barley, package = 'paar') #Convert to an sf object barley <- st_as_sf(barley, coords = c("X", "Y"), crs = 32720) depurated <- depurate(barley, "Yield") # Summary of depurated data summary(depurated) # Keep only depurate data depurated_data <- depurated$depurated_data # Combine the condition for all data all_data_condition <- cbind(depurated, barley)
Performs a vectorized fuzzy k-means clustering, this procedure it is not spatial. The function is almost a wrapper of the function cmeans from the package e1071. Is intended to be used when 'KM-sPC' procedure is not possible because data set has only 1 variable.
fuzzy_k_means( data, variables, number_cluster = 3:5, fuzzyness = 1.2, distance = "euclidean" )
fuzzy_k_means( data, variables, number_cluster = 3:5, fuzzyness = 1.2, distance = "euclidean" )
data |
sf object |
variables |
variables to use for clustering, if missing, all numeric variables will be used |
number_cluster |
|
fuzzyness |
A number greater than 1 giving the degree of fuzzification. |
distance |
|
a list with classification results and indices to select best number of clusters.
library(sf) data(wheat, package = 'paar') # Transform the data.frame into a sf object wheat_sf <- st_as_sf(wheat, coords = c('x', 'y'), crs = 32720) # Run the fuzzy_k_means function fuzzy_k_means_results <- fuzzy_k_means(wheat_sf, variables = 'Tg', number_cluster = 2:4) # Print the summaryResults fuzzy_k_means_results$summaryResults # Print the indices fuzzy_k_means_results$indices # Print the cluster head(fuzzy_k_means_results$cluster, 5) # Combine the results in a single object wheat_clustered <- cbind(wheat_sf, fuzzy_k_means_results$cluster) # Plot the results plot(wheat_clustered[, "Cluster_2"])
library(sf) data(wheat, package = 'paar') # Transform the data.frame into a sf object wheat_sf <- st_as_sf(wheat, coords = c('x', 'y'), crs = 32720) # Run the fuzzy_k_means function fuzzy_k_means_results <- fuzzy_k_means(wheat_sf, variables = 'Tg', number_cluster = 2:4) # Print the summaryResults fuzzy_k_means_results$summaryResults # Print the indices fuzzy_k_means_results$indices # Print the cluster head(fuzzy_k_means_results$cluster, 5) # Combine the results in a single object wheat_clustered <- cbind(wheat_sf, fuzzy_k_means_results$cluster) # Plot the results plot(wheat_clustered[, "Cluster_2"])
MULTISPATI-PCA clustering
kmspc( data, variables, number_cluster = 3:5, explainedVariance = 70, ldist = 0, udist = 40, center = TRUE, fuzzyness = 1.2, distance = "euclidean", zero.policy = FALSE, only_spca_results = TRUE, all_results = FALSE )
kmspc( data, variables, number_cluster = 3:5, explainedVariance = 70, ldist = 0, udist = 40, center = TRUE, fuzzyness = 1.2, distance = "euclidean", zero.policy = FALSE, only_spca_results = TRUE, all_results = FALSE )
data |
sf object |
variables |
variables to use for clustering, if missing, all numeric variables will be used |
number_cluster |
|
explainedVariance |
|
ldist |
|
udist |
|
center |
a logical or numeric value, centring option if TRUE, centring by the mean if FALSE no centring if a numeric vector, its length must be equal to the number of columns of the data frame df and gives the decentring |
fuzzyness |
A number greater than 1 giving the degree of fuzzification. |
distance |
|
zero.policy |
default NULL, use global option value; if FALSE stop with error for any empty neighbors sets, if TRUE permit the weights list to be formed with zero-length weights vectors |
only_spca_results |
|
all_results |
|
a list with classification results and indices to select best number of clusters.
library(sf) data(wheat, package = 'paar') # Transform the data.frame into a sf object wheat_sf <- st_as_sf(wheat, coords = c('x', 'y'), crs = 32720) # Run the kmspc function kmspc_results <- kmspc(wheat_sf, number_cluster = 2:4) # Print the summaryResults kmspc_results$summaryResults # Print the indices kmspc_results$indices # Print the cluster head(kmspc_results$cluster, 5) # Combine the results in a single object wheat_clustered <- cbind(wheat_sf, kmspc_results$cluster) # Plot the results plot(wheat_clustered[, "Cluster_2"])
library(sf) data(wheat, package = 'paar') # Transform the data.frame into a sf object wheat_sf <- st_as_sf(wheat, coords = c('x', 'y'), crs = 32720) # Run the kmspc function kmspc_results <- kmspc(wheat_sf, number_cluster = 2:4) # Print the summaryResults kmspc_results$summaryResults # Print the indices kmspc_results$indices # Print the cluster head(kmspc_results$cluster, 5) # Combine the results in a single object wheat_clustered <- cbind(wheat_sf, kmspc_results$cluster) # Plot the results plot(wheat_clustered[, "Cluster_2"])
Print paar objects
## S3 method for class 'paar' print(x, n = 3, ...)
## S3 method for class 'paar' print(x, n = 3, ...)
x |
an object used to select a method. |
n |
an integer vector specifying maximum number of rows or elements to print. |
... |
further arguments passed to or from other methods. |
invisible object x
Print summarized paar object
## S3 method for class 'summary.paar' print(x, digits, ...)
## S3 method for class 'summary.paar' print(x, digits, ...)
x |
an object used to select a method. |
digits |
minimal number of significant digits, see
|
... |
further arguments passed to or from other methods. |
A data.frame with the summarized condition of the object.
Remove borders
remove_border(x, crs = NULL, buffer, poly_border = NULL)
remove_border(x, crs = NULL, buffer, poly_border = NULL)
x |
an |
crs |
coordinate reference system: integer with the EPSG code,
or character with proj4string to convert coordinates if |
buffer |
|
poly_border |
|
Removes all points from x
that are buffer
meters from
boundary.
Removes spatial outliers using Local Moran's I statistic and moran scatterplot.
remove_inlier( x, y, ldist = 0, udist = 40, criteria = c("LM", "MP"), zero.policy = NULL )
remove_inlier( x, y, ldist = 0, udist = 40, criteria = c("LM", "MP"), zero.policy = NULL )
x |
an |
y |
|
ldist |
|
udist |
|
criteria |
|
zero.policy |
default NULL, use global option value; if FALSE stop with error for any empty neighbors sets, if TRUE permit the weights list to be formed with zero-length weights vectors |
Removes outliers
remove_outlier(x, y, ylimitmax = NA, ylimitmin = 0, sdout = 3)
remove_outlier(x, y, ylimitmax = NA, ylimitmin = 0, sdout = 3)
x |
an |
y |
|
ylimitmax |
|
ylimitmin |
|
sdout |
|
Performs a modified version of the t test to assess the correlation between spatial processes. See SpatialPack::modified.ttest for details.
spatial_t_test(data, variables)
spatial_t_test(data, variables)
data |
|
variables |
|
a data.frame with the correlation and p-value for each pair of variables
Summarizing paar objects
## S3 method for class 'paar' summary(object, ...)
## S3 method for class 'paar' summary(object, ...)
object |
an object for which a summary is desired. |
... |
additional arguments affecting the summary produced. |
An object of class summary.paar (data.frame) with the following columns:
condition
a character vector with the final condition.
n
a numeric vector with the number of rows for each condition.
percentage
a numeric vector with the percentage of rows for each condition.
A database from a wheat (Triticum aestivum L.) production field (60 ha) under continuous agriculture, located in south-eastern Pampas, Argentina.
wheat
wheat
A data frame with 5982 rows and 7 variables:
X coordinate, in meters
Y coordinate, in meters
apparent electrical conductivity taken at 0–30 cm
apparent electrical conductivity taken at 0–90 cm
elevation, in meters
soil depth, in centimeters
wheat grain yield
Coordinate reference system is "WGS 84 / UTM zone 20S", epsg:32720 Wheat grain yield was recorded in 2009 using calibrated commercial yield monitors mounted on combines equipped with DGPS. Soil ECa measurements were taken using Veris 3100 (VERIS technologies enr., Salina, KS, USA). Soil depth was measured using a hydraulic penetrometer on a 30 × 30 m regular grid (Peralta et al., 2015). Re-gridding was performed to obtain values of all variables at each intersection point of a 10 × 10 m grid.
N.R. Peralta, J.L. Costa, M. Balzarini, M. Castro Franco, M. Córdoba, D. Bullock Delineation of management zones to improve nitrogen management of wheat Comput. Electron. Agric., 110 (2015), pp. 103-113, 10.1016/j.compag.2014.10.017
Paccioretti, P., Córdoba, M., & Balzarini, M. (2020). FastMapping: Software to create field maps and identify management zones in precision agriculture. Computers and Electronics in Agriculture, 175, 105556.