Commit 93ff9809 authored by Georges Kunstler's avatar Georges Kunstler
Browse files

modified Paracou and Swiss

No related merge requests found
Showing with 45 additions and 10 deletions
+45 -10
...@@ -8,6 +8,19 @@ ...@@ -8,6 +8,19 @@
###### ######
###### ######
## FUNCTION TO PLOT MAP OF TREE ## FUNCTION TO PLOT MAP OF TREE
##' .. Function to plot map of tree with circle function of their dbh..
##'
##' .. content for \details{} ..
##' @title
##' @param plot.select the plot for which draw the map
##' @param x
##' @param y
##' @param plot vectore of plot id for each tree
##' @param D diameter in cm
##' @param inches controling the circle size
##' @param ...
##' @return
##' @author Kunstler
fun.circles.plot <- function(plot.select,x,y,plot,D,inches,...){ fun.circles.plot <- function(plot.select,x,y,plot,D,inches,...){
x.t <- x[plot==plot.select] x.t <- x[plot==plot.select]
y.t <- y[plot==plot.select] y.t <- y[plot==plot.select]
...@@ -108,8 +121,20 @@ print("columns removed") ...@@ -108,8 +121,20 @@ print("columns removed")
return( (data.merge)) return( (data.merge))
} }
#### function with X Y coordinates based on a neighborhood of radius R ####
##' .. function compute competition index with X Y coordinates based on a neighborhood of radius R ..
##'
##' .. content for \details{} ..
##' @title
##' @param obs.id id of the observation (if one tree as multiple growth measurement one obs.id per measurment
##' @param xy.table table with x.y of teh individual
##' @param diam diam in cm
##' @param sp species
##' @param Rlim radius of neighborhood search
##' @param parallel run in paralle or not ?
##' @param rpuDist run with GPU distance computation
##' @return a data frame with nrow = length of obs.id and ncol =unique(sp)
##' @author Kunstler
BA.SP.FUN.XY <- function(obs.id,xy.table,diam,sp,Rlim,parallel=FALSE,rpuDist=FALSE){ BA.SP.FUN.XY <- function(obs.id,xy.table,diam,sp,Rlim,parallel=FALSE,rpuDist=FALSE){
rownames(xy.table) <- obs.id rownames(xy.table) <- obs.id
if(rpuDist){ if(rpuDist){
......
### MERGE paracou DATA ### MERGE paracou DATA
### Edited by FH ### Edited by FH
rm(list = ls()); source("./R/format.function.R"); library(reshape) rm(list = ls())
source("./R/format.function.R")
library(reshape)
######################### #########################
## READ DATA ## READ DATA
#################### ####################
### read individuals tree data ### read individuals tree data
data.paracou <- read.table("./data/raw/DataParacou/20130717_paracou_1984_2012.csv",header=TRUE,stringsAsFactors=FALSE,sep = ";", na.strings = "NULL") data.paracou <- read.table("./data/raw/DataParacou/20130717_paracou_1984_2012.csv",
header=TRUE,stringsAsFactors=FALSE,sep = ";", na.strings = "NULL")
#barplot(apply(!is.na(data.paracou[,paste("circ_",1984:2012,sep="")]),MARGIN=2,FUN=sum),las=3) #barplot(apply(!is.na(data.paracou[,paste("circ_",1984:2012,sep="")]),MARGIN=2,FUN=sum),las=3)
# select good columns # select good columns
...@@ -16,9 +19,12 @@ data.paracou <- data.paracou[,c("foret","parcelle","carre","arbre","vernaculaire ...@@ -16,9 +19,12 @@ data.paracou <- data.paracou[,c("foret","parcelle","carre","arbre","vernaculaire
colnames(data.paracou) <- c("forest","plot","subplot","tree","vernacular","taxonid","x","y","circum2001","code2001","circum2005","code2005","circum2009","code2009","yeardied","typedeath") colnames(data.paracou) <- c("forest","plot","subplot","tree","vernacular","taxonid","x","y","circum2001","code2001","circum2005","code2005","circum2009","code2009","yeardied","typedeath")
### change numeric separator ### change numeric separator
for(k in 7:14) { numeric.col.name <- c("x","y","circum2001","code2001","circum2005","code2005","circum2009","code2009")
data.paracou[,k] <- gsub(",",".",data.paracou[,k]); data.paracou[,k] <- as.numeric(data.paracou[,k]) } ## Replace all , in decimals with . for(k in numeric.col.name){
data.paracou$treeid <- apply(data.paracou[,1:4],1,paste,collapse="."); ## Create a tree id data.paracou[,k] <- gsub(",",".",data.paracou[,k]); data.paracou[,k] <- as.numeric(data.paracou[,k])
} ## Replace all , in decimals with .
data.paracou$treeid <- apply(data.paracou[,c("plot","subplot","tree")],1,paste,collapse="."); ## Create a tree id
data.paracou <- data.paracou[,c(ncol(data.paracou),1:(ncol(data.paracou)-1))] data.paracou <- data.paracou[,c(ncol(data.paracou),1:(ncol(data.paracou)-1))]
## ## plot each plot ## ## plot each plot
......
...@@ -11,8 +11,12 @@ data.swiss2 <- read.csv("./data/raw/DataSwiss/LFI23.csv",header=TRUE,stringsAsFa ...@@ -11,8 +11,12 @@ data.swiss2 <- read.csv("./data/raw/DataSwiss/LFI23.csv",header=TRUE,stringsAsFa
data.swiss3 <- read.csv("./data/raw/DataSwiss/LFI34.csv",header=TRUE,stringsAsFactors =FALSE) data.swiss3 <- read.csv("./data/raw/DataSwiss/LFI34.csv",header=TRUE,stringsAsFactors =FALSE)
data.swiss <- rbind(data.swiss1, data.swiss2, data.swiss3) data.swiss <- rbind(data.swiss1, data.swiss2, data.swiss3)
rm(data.swiss1, data.swiss2, data.swiss3) rm(data.swiss1, data.swiss2, data.swiss3)
data.swiss <- data.swiss[order(data.swiss$BANR),]; data.swiss <- data.swiss[,c(2:19)] data.swiss <- data.swiss[order(data.swiss$BANR),]
colnames(data.swiss) <- c("Inventid","siteid","treeid","x","y","spcode","sp.name","year","dbh1","dbh2","ba1","ba2","ba_diff","dbh_diff","repfactor1","repfactor2","ht1","ht2") data.swiss <- data.swiss[,c("INVNR","CLNR","BANR","X","Y","BAUMART","TEXT","VEGPER",
"BHD1","BHD2","BA1","BA2","BAI","BHD_DIFF","RPSTZ1","RPSTZ2","HOEHE1","HOEHE2")]
colnames(data.swiss) <- c("Inventid","siteid","treeid","x","y","spcode","sp.name","year",
"dbh1","dbh2","ba1","ba2","ba_diff","dbh_diff","repfactor1","repfactor2","ht1","ht2")
## Do not need to read in spp list as it is already available in data.swiss ## Do not need to read in spp list as it is already available in data.swiss
...@@ -42,7 +46,7 @@ data.swiss$htot <- data.swiss$ht1 ## height of tree in m ...@@ -42,7 +46,7 @@ data.swiss$htot <- data.swiss$ht1 ## height of tree in m
## ECOREGION ## ECOREGION
################### ###################
## Ecoregion not available for swiss data ## Ecoregion not available for swiss data
data.swiss$ecocode <- rep("A",nrow(data.swiss))
###################### ######################
## PERCENT DEAD ## PERCENT DEAD
################### ###################
......
No preview for this file type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment