Skip to content

Instantly share code, notes, and snippets.

@chichacha
Created December 1, 2018 05:21
Show Gist options
  • Save chichacha/ef6187f5e02892cdc41edeee6b5ad485 to your computer and use it in GitHub Desktop.
Save chichacha/ef6187f5e02892cdc41edeee6b5ad485 to your computer and use it in GitHub Desktop.
Quick Viz with Soil Data using soilDB
library(soilDB)
library(tidyverse)
# load sample data from the soilDB package
data(loafercreek, package = "soilDB")
sample_set <- loafercreek@horizons %>% filter(!is.na(soil_color))
golden_angle <- pi*(3-sqrt(5))
sample_set <-mini_set %>%
group_by(texcl) %>%
arrange(hzdept) %>% ## i want shallower depth soil to appear closer to inner circle.
mutate(t = row_number(), ## append index within a group
x = sqrt(t) * cos(t * golden_angle), ## x-position for spiral
y = sqrt(t) * sin(t * golden_angle)) ## y-position for spiral
sample_set %>%
ggplot(aes(x=x,y=y)) +
geom_point(aes(color=soil_color)) +
scale_color_identity() +
facet_wrap(~texcl, ncol=5) +
coord_fixed() +
theme_void() +
labs(title="Soil Colour by texcl (Texture Class?!?)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment