R/get_soil.R

Defines functions get_soil_esdb

Documented in get_soil_esdb

#' get soil data from the European Soil DataBase (ESDB), using a local repository for GIS files.
#'
#' @param lat latitude of the geographical location in decimal degrees (WGS84)
#' @param lon longitude of the geographical location in decimal degrees (WGS84)
#' @param data dataframe created from ESDB GIS files as made available by the JRC lab for research usage.
#'
#' @return a dataframe of soil properties
#' @export

get_soil_esdb <- function(lat, lon, data=data_soil) {

  # get closer grid position
  index <- which.min(sqrt((data$lat-lat)^2 + (data$lon-lon)^2))

  # extract DB features
  data_soil <- data %>% dplyr::slice(index) %>% dplyr::select(-(x:lat))

  return(data_soil)

}
picasa/agroenv documentation built on Nov. 17, 2022, 3:05 a.m.