# NOT RUN {
if(requireNamespace("curl") &
curl::has_internet()) {
# get spatial data for a single mukey
single.mukey <- fetchSDA_spatial(x = "2924882")
# demonstrate fetching full extent (multi-mukey) of national musym
full.extent.nmusym <- fetchSDA_spatial(x = "2x8l5", by = "nmusym")
# compare extent of nmusym to single mukey within it
if(require(sp)) {
plot(full.extent.nmusym, col = "RED",border=0)
plot(single.mukey, add = TRUE, col = "BLUE", border=0)
}
# demo adding a field (`muname`) to attribute table of result
head(fetchSDA_spatial(x = "2x8l5", by="nmusym", add.fields="muname"))
}
# }
Run the code above in your browser using DataLab