[output published (also) in: http://rpubs.com/scotti/SPA_PinusPinea_Tortoli]
## Warning: package 'googlesheets' was built under R version 3.3.3
## Warning: package 'dplyr' was built under R version 3.3.3
## # A tibble: 2 x 10
## sheet_title author perm version updated
## <chr> <chr> <chr> <chr> <dttm>
## 1 TransectPinusPinea scotti rw old 2017-09-09 11:12:18
## 2 TransectPinusPinea_v2 scotti rw old 2016-12-09 10:33:58
## # ... with 5 more variables: sheet_key <chr>, ws_feed <chr>,
## # alternate <chr>, self <chr>, alt_key <chr>
## Sheet successfully identified: "TransectPinusPinea"
## Sheet ' PointPatternWithMarks ' found.
## Accessing worksheet titled 'PointPatternWithMarks'.
## Parsed with column specification:
## cols(
## Area = col_character(),
## IdPoint = col_character(),
## X = col_double(),
## Y = col_double(),
## `H [m]` = col_double(),
## `N palchi` = col_integer(),
## AreaInsid = col_double(),
## Note = col_character(),
## Note_cod = col_character(),
## KEY = col_character(),
## n_el_gruppo = col_integer(),
## sum_d_coll_sq = col_integer(),
## n_fusti = col_integer(),
## sum_d130sq = col_integer()
## )
## Classes 'tbl_df', 'tbl' and 'data.frame': 102 obs. of 15 variables:
## $ Area : chr "3" "3" "3" "3" ...
## $ IdPoint : chr "C1" "C2" "C3" "C4" ...
## $ X : num 5.4 14.6 23 26.1 26.8 29.2 26.6 29.2 32.4 33.3 ...
## $ Y : num 9.3 4.8 5.5 9.9 4.3 4 4.4 4.4 0.7 4.3 ...
## $ H [m] : num 7.5 2.4 6 3.6 3.4 6.7 3.6 3.2 3.3 8 ...
## $ N palchi : int 13 8 10 8 7 11 8 9 6 13 ...
## $ AreaInsid : num 63.65 4.95 23.01 4.81 2.88 ...
## $ Note : chr NA NA NA NA ...
## $ Note_cod : chr "A" "A" "A" "A" ...
## $ KEY : chr "3C1" "3C2" "3C3" "3C4" ...
## $ n_el_gruppo : int 1 1 1 1 1 1 2 1 1 1 ...
## $ sum_d_coll_sq: int 7396 169 1600 100 49 1600 148 169 36 1444 ...
## $ n_fusti : int 3 1 3 1 1 2 2 1 1 2 ...
## $ sum_d130sq : int 1785 9 509 49 16 845 49 25 4 1025 ...
## $ nPf : Factor w/ 13 levels "2","3","4","5",..: 12 7 9 7 6 10 7 8 5 12 ...
## - attr(*, "spec")=List of 2
## ..$ cols :List of 14
## .. ..$ Area : list()
## .. .. ..- attr(*, "class")= chr "collector_character" "collector"
## .. ..$ IdPoint : list()
## .. .. ..- attr(*, "class")= chr "collector_character" "collector"
## .. ..$ X : list()
## .. .. ..- attr(*, "class")= chr "collector_double" "collector"
## .. ..$ Y : list()
## .. .. ..- attr(*, "class")= chr "collector_double" "collector"
## .. ..$ H [m] : list()
## .. .. ..- attr(*, "class")= chr "collector_double" "collector"
## .. ..$ N palchi : list()
## .. .. ..- attr(*, "class")= chr "collector_integer" "collector"
## .. ..$ AreaInsid : list()
## .. .. ..- attr(*, "class")= chr "collector_double" "collector"
## .. ..$ Note : list()
## .. .. ..- attr(*, "class")= chr "collector_character" "collector"
## .. ..$ Note_cod : list()
## .. .. ..- attr(*, "class")= chr "collector_character" "collector"
## .. ..$ KEY : list()
## .. .. ..- attr(*, "class")= chr "collector_character" "collector"
## .. ..$ n_el_gruppo : list()
## .. .. ..- attr(*, "class")= chr "collector_integer" "collector"
## .. ..$ sum_d_coll_sq: list()
## .. .. ..- attr(*, "class")= chr "collector_integer" "collector"
## .. ..$ n_fusti : list()
## .. .. ..- attr(*, "class")= chr "collector_integer" "collector"
## .. ..$ sum_d130sq : list()
## .. .. ..- attr(*, "class")= chr "collector_integer" "collector"
## ..$ default: list()
## .. ..- attr(*, "class")= chr "collector_guess" "collector"
## ..- attr(*, "class")= chr "col_spec"
Spatial patterns windows are, partially, undefined. The width is fixed to 10m while the length is open and has to be estimated!!
library(spatstat)
## Warning: package 'spatstat' was built under R version 3.3.3
## Loading required package: nlme
##
## Attaching package: 'nlme'
## The following object is masked from 'package:dplyr':
##
## collapse
## Loading required package: rpart
##
## spatstat 1.52-1 (nickname: 'Apophenia')
## For an introduction to spatstat, type 'beginner'
##
## Note: R version 3.3.2 (2016-10-31) is more than 9 months old; we strongly recommend upgrading to the latest version
Areas <- unique(ppwm$Area)
t_windows <- list()
for(tid in Areas) t_windows[[tid]] <- ripras(ppwm$X[ppwm$Area==tid],ppwm$Y[ppwm$Area==tid], shape = "rectangle")
# ripras(): Estimate window from points alone
reduced <- c(1, 2, 3, 4, 6, 5, 7)
ppwm0 <- ppwm
ppwm <- ppwm[, reduced]
names(ppwm)[5:7] <- c("#whorls", "height [m]", "crown [m^2]")
trss <- solist()
# To display transects as seen from the see
# exchange x and y
# mirror on the negative side the y ==> K=-1
K <- -1
for(tid in Areas) {
trs <- ppp(ppwm$Y[ppwm$Area==tid],K*c(ppwm$X[ppwm$Area==tid])
, yrange = range(K*t_windows[[tid]]$xrange), xrange = c(-10, 10)
, marks = ppwm[ppwm$Area==tid, c(5:7)])
unitname(trs) <- "m"
# print(paste(tid,class(trs)))
trss[[length(trss)+1]] <- trs
}
names(trss)=paste("Trs-",Areas,sep="")
plot(as.solist(lapply(trss, density)), nrows=1, equal.scales=T, valign=T,
main = "", hsep=2, cex.main=.7,
equal.ribbon=TRUE, ribbon = T, ribside="left",
panel.end=function(i,y,...){contour(y, ...)})
# par(mar=c(0,0,2,0)),
# title(main="Density distribution", line =-1)
Axis(trss, side=4, cex.axis=.6, at=seq(100,20,-20), labels = seq(0,80,20), line = -3)
text(150,70,"distance [m]", srt = 90)
library("PerformanceAnalytics", lib.loc="~/R/win-library/3.3")
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
##
## first, last
##
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
ow <- options("warn")[[1]]
options(warn = -1)
for(i in 1:4) chart.Correlation(marks(trss[[i]])
, histogram=TRUE, pch=19
, main=names(trss)[i])
options(warn = ow)
for(i in 1:length(trss)) {
tid <- names(trss)[i]
trs <- trss[[tid]]
plot(trs, cex.main=1.1, main="",
hsep=0, par(mar=c(0,0.5,0,0), cex=.6), mar.panel=c(0,0,0,.9))
title(main = paste("Marks in",tid), line = -2)
}
## Warning: Interpretation of arguments maxsize and markscale has changed (in
## spatstat version 1.37-0 and later). Size of a circle is now measured by its
## diameter.
# which.marks = c(9, 1, 3),
# main.panel=c("#whorls", "height [m]", "crown [m^2]"),
Kl <- as.anylist(lapply(trss, Kest))
for(i in 1:length(Kl)) {
leg <- plot(Kl[[i]], legend = F, main=names(Kl)[[i]])
legend("topleft",legend = leg$key, lty=leg$lty, col=leg$col)
}
pmkc <- function(x, m) plot(main=paste(names(trss)[x],":"
,names(trss[[1]]$marks)[m])
,markcorr(setmarks(unmark(trss[[x]])
,marks(trss[[x]])[[m]])))
for(m in 1:length(marks(trs))) {
for(i in 1:length(trss)) pmkc(i, m)
}