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