title: “Marganai project - remote sensing” author: - affiliation: NuoroForestrySchool name: “Antonio Ganga” date: “03 novembre 2018” output: html_document: default html_notebook: default pdf_document: default keywords: data wrangling # subtitle: Just first checks abstract: TO BE COMPLETED —
library(tidyverse)
library(googlesheets)
suppressMessages(library(dplyr))
# gs_ls()
Gsheets <-
"https://docs.google.com/spreadsheets/d/1pvEgtHwW4caUYfmZWt5r89A7L7gFGOKR0_vtF7aSMgQ" %>%
gs_url()
## Sheet-identifying info appears to be a browser URL.
## googlesheets will attempt to extract sheet key from the URL.
## Putative key: 1pvEgtHwW4caUYfmZWt5r89A7L7gFGOKR0_vtF7aSMgQ
## Sheet successfully identified: "table"
Gsheets %>%
gs_ws_ls()
## [1] "2016" "2018" "morph" "tot"
tot.table <- Gsheets %>% gs_read("tot")
## Accessing worksheet titled 'tot'.
## Parsed with column specification:
## cols(
## id = col_integer(),
## X = col_number(),
## Y = col_number(),
## Aspect = col_number(),
## TWI = col_number(),
## ELEV = col_number(),
## SLOPE = col_number(),
## RI_2016 = col_character(),
## VARI_2016 = col_character(),
## TGI_2016 = col_character(),
## NDVI_2016 = col_character(),
## RI_2018 = col_character(),
## VARI_2018 = col_character(),
## TGI_2018 = col_character(),
## NDVI_2018 = col_character(),
## `<U+0394>NDVI` = col_character(),
## `<U+0394>VARI` = col_character(),
## `<U+0394>RI` = col_number(),
## `<U+0394>TGI` = col_number()
## )
library(rpart)
# https://cran.r-project.org/web/packages/rpart/vignettes/longintro.pdf
NDVI_mod <- rpart(`<U+0394>NDVI` ~ X + Y + Aspect + TWI + ELEV + SLOPE, tot.table)
summary(NDVI_mod, cp = 0.1)
## Call:
## rpart(formula = `<U+0394>NDVI` ~ X + Y + Aspect + TWI + ELEV +
## SLOPE, data = tot.table)
## n= 29
##
## CP nsplit rel error xerror xstd
## 1 0.03571429 0 1.0000000 1.035714 0
## 2 0.01000000 2 0.9285714 1.035714 0
##
## Variable importance
## X ELEV TWI SLOPE Y
## 39 29 21 8 2
##
## Node number 1: 29 observations
## predicted class=0,03314 expected loss=0.9655172 P(node) =1
## class counts: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## probabilities: 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034 0.034
plot(NDVI_mod, uniform = TRUE, branch = 0.4, compress = TRUE)
text(NDVI_mod, use.n = TRUE)
rmarkdown::render("provaCART.Rmd")