if (interactive()) {
# create a simple data.frame for a list of locations and their coordinates
Location <- c('Tel-Hadya', 'Terbol', 'Marchouch')
Latitude <- c(36.016, 33.808, 33.616)
Longitude <- c(36.943, 35.991, -6.716)
sites <- data.frame(Location, Latitude, Longitude)
# initiate, download, and setup the HWSD v2 in a given local directory
hwsd2 <- ini_hwsd2(data_path = 'C:/Users/Kel-shamaa/Downloads/HWSD v2/')
# query soil attributes for given sites using the HWSD v2 connection object
#
# sequence parameter, range between 1 and 12 (max), 1 is the dominant soil.
# returned df has SHARE column refers to share%
#
# layer parameter refers to depth layer (D1 to D7).
# returned df has TOPDEP/BOTDEP columns represent top/bottom layer depth in cm.
sites <- get_hwsd2(df = sites,
con = hwsd2,
x = 'Longitude',
y = 'Latitude',
sequence = 1,
layer = 'D1')
}
Run the code above in your browser using DataLab