Redcedar Data Analyses Instructions
library(tidyverse)
library(randomForest)
library(caret)
library(rpart)
library(knitr)
library(corrplot)
library(soilDB)
library(ggmap)

Approach

A previous analysis with ssurgo data collected through a combination of qGIS and PostGIS was completed and archived.

The approach of the analysis on this page was to explore methods for integrating ssurgo data with r commands.

Unfortunately, working with the soilDB package requires queries to interact with the ‘soil data access’ SDA web service using a language similar to SQL. Therefore, the below code may not look like r code.

TIMEOUT - pausing this analysis :)

Data Wrangling

Import iNat Data - Empirical Tree Points (Response variables)

The steps for wrangling the data are described here.

#data <- read.csv('https://github.com/jmhulbert/open/raw/main/redcedar/data/data-modified.csv')
data <- read.csv('~/ServerFiles/open/redcedar/data/data-modified.csv') #ofline
#data$id <- as.character(data$id)

Prepare iNat data for soilDB

#names(data[c(1:30)])
#summary(as.factor(data$place_country_name))

Filter data to observations in USA

data <- data %>% filter(place_country_name=="United States")
ggplot(data) +
  geom_point(aes(x = longitude, y = latitude), color = "blue") +
  xlab("Longitude") +
  ylab("Latitude") +
  theme_minimal()

gps <- data[c(2,24,25)] #subset data to only include id and gps coordinates
gps <- gps %>% `colnames<-`(c("id","lat","lon"))
#gps$lat <- round(gps$lat,5)
#gps$lon <- round(gps$lon,6)
# test dataset
coordinates <- data.frame(
  lat = c(35.2812, 35.2965, 35.4237),
  lon = c(-120.6766, -120.8565, -120.7661)
)
# need to figure out how to use fetchSDA correctly
# gssurgo <- fetchSDA_spatial(coordinates)
?fetchSDA_spatial
#gssurgo <- get_component_from_SDA(gps)