# NOT RUN {
## install.packages("aqp", repos="http://R-Forge.R-project.org")
library(aqp)
library(fossil)
library(plyr)
data(ca630)
## Promote to SoilProfileCollection
ca <- join(ca630$lab, ca630$site, type='inner')
depths(ca) <- pedon_key ~ hzn_top + hzn_bot
## extract site data
site(ca) <- ~ mlra + ssa + lon + lat + cntrl_depth_to_top + cntrl_depth_to_bot + sampled_taxon_name
# generate SpatialPoints
library(sp)
coordinates(ca) <- ~ lon + lat
## assign CRS data
proj4string(ca) <- "+proj=longlat +datum=NAD83"
## plot changes in base saturation by sum of cations method (pH 8.2):
kml(ca, method = "depth_function", file.name = "ca_bs_8_2.kml",
var.name="bs_8.2", balloon = TRUE)
## plot changes in cation exchange capacity by sum of cations method (pH 8.2):
kml(ca, file.name = "ca_CEC8_2.kml", var.name="CEC8.2", IconColor = "#ff009000")
## plot soil profile as 'block':
kml(ca, file.name = "ca_CEC8_2_block.kml", var.name="CEC8.2", balloon = TRUE)
# }
Run the code above in your browser using DataLab