landscape$factor[is.na(landscape$factor)] <- 1
rstudio::viewData(landscape)
as.character(landscape[1:10, 5:15])
as.character(landscape[, 5:15])
as.character(landscape[, 5])
as.character(landscape[, 6])
as.character(landscape[, 7])
?read.table
landscape <- read.table('landscape.csv', sep='\t', head=T, colClasses='character')
rstudio::viewData(landscape)
str(landscape)
landscape$factor <- as.factor(landscape$factor)
landscape$factor
landscape <- read.table('landscape.csv', sep='\t', head=T, colClasses='character')
landscape$factor <- as.numeric(landscape$factor)
landscape$factor
landscape$factor[is.na(landscape$factor)] <- 1
landscape$factor
rstudio::viewData(landscape)
landscape.trees <- landscape[, 6:ncol(landscape)]
rstudio::viewData(landscape.trees)
which(landscape.trees[1, ]=='d')
which(landscape.trees[3, ]=='d')
which(landscape.trees[5, ]=='d')
which(landscape.trees[7, ]=='d')
which(landscape.trees[9, ]=='d')
which(landscape.trees[11, ]=='d')
rstudio::viewData(landscape.trees)
which(landscape.trees[13, ]=='d')
apply(landscape, 1, function (x) which(x=='d'))
apply(landscape.trees, 1, function (x) which(x=='d'))
unlist(apply(landscape.trees, 1, function (x) which(x=='d')))
which(landscape.trees[11, ]=='d')
apply(landscape.trees, 1, function (x) which(x=='d'))
sapply(apply(landscape.trees, 1, function (x) which(x=='d')), identity)
sapply(apply(landscape.trees, 1, function (x) which(x=='d')), length)
if(0) 1
if(0) print(1)
if(!) print(1)
if(1) print(1)
sapply(apply(landscape.trees, 1, function (x) which(x=='d')),
function(x) if length(x) x else 0)
sapply(apply(landscape.trees, 1, function (x) which(x=='d')),
function(x) if length(x) x; else 0)
sapply(apply(landscape.trees, 1, function (x) which(x=='d')),
function(x) if (length(x)) x; else 0)
sapply(apply(landscape.trees, 1, function (x) which(x=='d')),
function(x) if (length(x)) x else 0)
as.numeric(landscape.trees)
dominant.trees <- sapply(apply(landscape.trees, 1, function (x) which(x=='d')),
function(x) if (length(x)) x else 0)
rstudio::viewData(landscape.trees)
landscape.trees[landscape.trees=='d'] <- ''
rstudio::viewData(landscape.trees)
unique(landscape.trees)
unique(unlist(landscape.trees))
table(unlist(landscape.trees))
for (tree in names(landscape.trees)) {
landscape.trees[, tree] <- as.numericlandscape.trees[, tree]
}
for (tree in names(landscape.trees)) {
landscape.trees[, tree] <- as.numeric(landscape.trees[, tree])
}
rstudio::viewData(landscape.trees)
table(unlist(landscape.trees))
?table
table(unlist(landscape.trees), useNA=T)
table(unlist(landscape.trees), useNA='yes')
table(unlist(landscape.trees), useNA='ifany')
landscape.trees[is.na(landscape.trees)] <- 0
rstudio::viewData(landscape.trees)
rowSums(landscape.trees)
rowSums(landscape.trees)[(1:129)*2 -1]
tree.sums <- rowSums(landscape.trees)
# count values for dominant trees
for (i in 1:nrow(landscape.trees)) {
if (dominant.trees[i]) {
landscape.trees[i, dominant.trees[i]] <- 10 - tree.sums[i]
}
}
rstudio::viewData(landscape.trees)
rowSums(landscape.trees)[(1:129)*2 -1]
cbind(landscape$type, rowSums(landscape.trees)[(1:129)*2 -1])
names(landscape)
cbind(landscape$vege, rowSums(landscape.trees)[(1:129)*2 -1])
cbind(landscape$veg, rowSums(landscape.trees)[(1:129)*2 -1])
cbind(landscape$veg, rowSums(landscape.trees))[(1:129)*2 -1, ]
rstudio::viewData(landscape)
landscape <- read.table('landscape.csv', sep='\t', head=T, colClasses='character')
landscape$factor <- as.numeric(landscape$factor)
landscape$factor[is.na(landscape$factor)] <- 1
landscape.trees <- landscape[, 6:ncol(landscape)]
# column numbers of dominant trees
dominant.trees <- sapply(apply(landscape.trees, 1, function (x) which(x=='d')),
function(x) if (length(x)) x else 0)
landscape.trees[landscape.trees=='d'] <- ''
# character to numeric
for (tree in names(landscape.trees)) {
landscape.trees[, tree] <- as.numeric(landscape.trees[, tree])
}
landscape.trees[is.na(landscape.trees)] <- 0
tree.sums <- rowSums(landscape.trees)
# count values for dominant trees
for (i in 1:nrow(landscape.trees)) {
if (dominant.trees[i]) {
landscape.trees[i, dominant.trees[i]] <- 10 - tree.sums[i]
}
}
cbind(landscape$veg, rowSums(landscape.trees))[(1:129)*2 -1, ]
rstudio::viewData(landscape.trees)
rstudio::viewData(landscape.trees)
sappply(names(landscape.trees), function(x) paste("names(landscape.trees) <- sub(\"", x))
sapply(names(landscape.trees), function(x) paste("names(landscape.trees) <- sub(\"", x))
sapply(names(landscape.trees), function(x) paste("names(landscape.trees) <- sub('", x))
sapply(names(landscape.trees), function(x) paste("names(landscape.trees) <- sub('",x))
sapply(names(landscape.trees), function(x) paste0("names(landscape.trees) <- sub('", x, ""))
sapply(names(landscape.trees), function(x) paste0("names(landscape.trees) <- sub('", x, "', '', names(landscape.trees))"))
sapply(names(landscape.trees), function(x) paste0("names(landscape.trees) <- sub('", x, "', '', names(landscape.trees))"))
x <-sapply(names(landscape.trees), function(x) paste0("names(landscape.trees) <- sub('", x, "', '', names(landscape.trees))"))
x
names(x) <- NULL
x
write(x, 'xxx')
names(landscape.trees) <- sub('Acer.campestre', 'ac', names(landscape.trees))
names(landscape.trees)
cbind(landscape$veg, landscape.trees$Q..rubra, landscape.trees$Quercus.rubra)
landscape <- read.table('landscape.csv', sep='\t', head=T, colClasses='character')
landscape$factor <- as.numeric(landscape$factor)
landscape$factor[is.na(landscape$factor)] <- 1
landscape.trees <- landscape[, 6:ncol(landscape)]
# column numbers of dominant trees
dominant.trees <- sapply(apply(landscape.trees, 1, function (x) which(x=='d')),
function(x) if (length(x)) x else 0)
landscape.trees[landscape.trees=='d'] <- ''
# character to numeric
for (tree in names(landscape.trees)) {
landscape.trees[, tree] <- as.numeric(landscape.trees[, tree])
}
landscape.trees[is.na(landscape.trees)] <- 0
tree.sums <- rowSums(landscape.trees)
# count values for dominant trees
for (i in 1:nrow(landscape.trees)) {
if (dominant.trees[i]) {
landscape.trees[i, dominant.trees[i]] <- 10 - tree.sums[i]
}
}
sort(names(landscape.trees))
names(landscape.trees) <- sub('Acer.campestre', 'ac', names(landscape.trees))
names(landscape.trees) <- sub('Acer.platanoides', 'apla', names(landscape.trees))
names(landscape.trees) <- sub('Acer.pseudoplatanus', 'apse', names(landscape.trees))
names(landscape.trees) <- sub('Betula.pendula', 'bp', names(landscape.trees))
names(landscape.trees) <- sub('Carpinus.betulus', 'cb', names(landscape.trees))
names(landscape.trees) <- sub('Fraxinus.sp.', 'fx', names(landscape.trees))
names(landscape.trees) <- sub('Larix.decidua', 'lx', names(landscape.trees))
names(landscape.trees) <- sub('Pinus.sylvestris', 'ps', names(landscape.trees))
names(landscape.trees) <- sub('Populus.tremula', 'pt', names(landscape.trees))
names(landscape.trees) <- sub('Quercus.sp.', 'q', names(landscape.trees))
names(landscape.trees) <- sub('Robinia.pseudacacia', 'rp', names(landscape.trees))
names(landscape.trees) <- sub('Sorbus.torminalis', 'st', names(landscape.trees))
names(landscape.trees) <- sub('Tilia.cordata', 'tc', names(landscape.trees))
names(landscape.trees) <- sub('Aesculus', 'ah', names(landscape.trees))
names(landscape.trees) <- sub('Q..rubra', 'qr', names(landscape.trees))
names(landscape.trees) <- sub('Alnus.glutinosa', 'aglu', names(landscape.trees))
names(landscape.trees) <- sub('Picea.abies', 'pa', names(landscape.trees))
names(landscape.trees) <- sub('Q..frainetto', 'qf', names(landscape.trees))
names(landscape.trees) <- sub('Q..cerris', 'qc', names(landscape.trees))
names(landscape.trees) <- sub('Acer.negundo', 'aneg', names(landscape.trees))
names(landscape.trees) <- sub('Salix.fragilis', 'sxfr', names(landscape.trees))
names(landscape.trees) <- sub('Salix.caprea', 'sxcap', names(landscape.trees))
names(landscape.trees) <- sub('Quercus.pubescens', 'qpub', names(landscape.trees))
names(landscape.trees) <- sub('Prunus.avium', 'prua', names(landscape.trees))
names(landscape.trees) <- sub('Pinus.nigra', 'pnig', names(landscape.trees))
names(landscape.trees) <- sub('Populus.canadensis', 'pcan', names(landscape.trees))
sort(names(landscape.trees))
rstudio::viewData(landscape.trees)
landscape[landscape$segment=='118']
landscape[landscape$segment=='118',]
?over
setwd('/media/Data/Dropbox/skola/dipl/data/gis/')
segments.pol <- readOGR(".", layer="segmentsPolygons")
plot(segments.pol)
segments.point <- readOGR(".", layer="segmentsPoints")
plot(segments.points, add=T)
segments.points <- readOGR(".", layer="segmentsPoints")
plot(segments.points, add=T)
over(segments.pol, segments.points)
plot(segments.pol[2:4, ], add=T, col='red')
plot(segments.pol[3:5, ], add=T, col='green')
segments.pol
segments.pol$area
which.min(segments.pol$area)
plot(segments.pol[71, ], col='blue', add=T)
segments.polygons <- readOGR(".", layer="segmentsPolygons")
segments.points <- readOGR(".", layer="segmentsPoints")
over(segments.pol, segments.points)
x <- over(segments.pol, segments.points)
str(x)
sort(x$id)
sort(x$id)-1:129
segments.points <- readOGR(".", layer="segmentsPoints")
x <- over(segments.pol, segments.points)
sort(x$id)-1:129
sort(x$id)
rstudio::viewData(landscape)
segments.points <- readOGR(".", layer="segmentsPoints")
sort(x$id)
segments.points <- readOGR(".", layer="segmentsPoints")
sort(x$id)
x <- over(segments.pol, segments.points)
sort(x$id)
segments.polygons <- readOGR(".", layer="segmentsPolygons")
x <- over(segments.pol, segments.points)
sort(x$id)
segments.points <- readOGR(".", layer="segmentsPoints")
segments.points$id
sort(segments.points$id)
sort(segments.points$id)-1:129
segments.polygons <- readOGR(".", layer="segmentsPolygons")
segments.points <- readOGR(".", layer="segmentsPoints")
sort(segments.points$id)-1:129
x <- over(segments.pol, segments.points)
sort(x$id)
length(x$id)
?length
sum(!is.na(x$id))
sort(segments.points$id)-1:129
x <- over(segments.polygons, segments.points)
sort(x$id)-1:129
x$id
plot(segments.polygons[is.na(x$id), ], add=T, col='yellow')
segments.polygons$id <- over(segments.polygons, segments.points)$id
segments.polygons$id
segments.polygons
c(segments.polygons, segments.polygons$id)
cbind(segments.polygons, segments.polygons$id)
segments.polygons@data
cbind(segments.polygons@data, segments.polygons$id)
segments.polygons@data <- cbind(segments.polygons@data, segments.polygons$id)
segments.polygons@data
setwd('/media/Data/skola/dipl/data/csv/working')
trees.50 <- read.table('trees50.csv', head=T)
rstudio::viewData(trees.50)
rowSums(trees50[trees50$treatment=='C', ])
rowSums(trees.50[trees.50$treatment=='C', ])
rowSums(trees.50[trees.50$treatment=='C', 4:13])
hist(rowSums(trees.50[trees.50$treatment=='C', 4:13]))
boxplot(rowSums(trees.50[trees.50$treatment=='C', 4:13]))
mean(rowSums(trees.50[trees.50$treatment=='C', 4:13]))
median(rowSums(trees.50[trees.50$treatment=='C', 4:13]))
rstudio::viewData(trees.50)
matrix(1:10)
matrix(1:100)
??sp
?sp
?over
?overlay
?rgeos
??rgeos
?geoR
landscape.trees[1:5,]
coords.plots[1:5,]
x <- buffer(coords.plots[1:5,], 500)
coords.plots@coords
x <- buffer(coords.plots@coords.nrs[1:5,], 500)
x <- buffer(coords.plots@coords[1:5,], 500)
?SpatialPoints
x <- buffer(SpatialPoints(coords.plots@coords[1:5,]), 500)
l2 = readWKT("LINESTRING(0 0,1 5,3 2)")
par(mfrow=c(2,3))
plot(gBuffer(l2,joinStyle="ROUND"));plot(l2,col='blue',add=TRUE);title("joinStyle: ROUND")
plot(gBuffer(l2,joinStyle="MITRE"));plot(l2,col='blue',add=TRUE);title("joinStyle: MITRE")
plot(gBuffer(l2,joinStyle="BEVEL"));plot(l2,col='blue',add=TRUE);title("joinStyle: BEVEL")
plot(gBuffer(l2,joinStyle="MITRE",mitreLimit=0.5));plot(l2,col='blue',add=TRUE);title("mitreLimit: 0.5")
plot(gBuffer(l2,joinStyle="MITRE",mitreLimit=1));plot(l2,col='blue',add=TRUE);title("mitreLimit: 1")
plot(gBuffer(l2,joinStyle="MITRE",mitreLimit=3));plot(l2,col='blue',add=TRUE);title("mitreLimit: 3")
x <- buffer(SpatialPoints(coords.plots@coords[1:5,]), width=500)
x <- buffer(SpatialPoints(coords.plots[1,]), width=500)
x <- buffer(coords.plots[1,], width=500)
x <- gBuffer(coords.plots[1:5,], 500)
plot(x)
x
x <- gBuffer(coords.plots[1:5,], width=500)
x
plot(x)
plot(segments.polygons)
par("mfrow")
par(mrfrow=c(1,1))
par(mfrow=c(1,1))
plot(segments.polygons)
plot(x, add=T, col='red')
x <- gBuffer(coords.plots[1:5,], width=500, quadsegs=20)
plot(segments.polygons)
plot(x, add=T, border='red')
x <- gBuffer(coords.plots[1:5,], width=500, quadsegs=20, capStyle='ROUND')
plot(x, add=T, border='red')
for (i in 1:nrow(coords.plots)) plot(gBuffer(coords.plots[i,], width=500, quadsegs=20, capStyle='ROUND'), add=T, border='green')
plot(segments.polygons)
x <- gBuffer(coords.plots[1,], width=500, quadsegs=20, capStyle='ROUND')
plot(x, add=T, border='red')
x <- gBuffer(coords.plots[1,], width=500, quadsegs=20)
x <- gBuffer(coords.plots[19,], width=500, quadsegs=20)
plot(x, add=T, border='green')
x <- gBuffer(coords.plots, width=500, quadsegs=20)
plot(x, add=T, border='green')
setwd('/media/Data/skola/dipl/data/csv/primary/')
trees50 <- read.table('podil_drevin.csv', sep='\t', head=T)
trees50 <- trees50[, seq_len(ncol(trees50)-4)]
trees50[is.na(trees50)] <- 0
trees50.circle <- aggregate(trees50[, -(1:4)],
list(trees50$opakovani, trees50$treatment, trees50$plocha),
function(x) {
round(sum(x[1:4]) / (50 * 4 * 4) * pi * 50^2) + x[5]
})
# remove non-present trees
trees.not.present <- which(colSums(trees50.circle[, 4:ncol(trees50.circle)]) == 0) + 3
trees50.circle <- trees50.circle[, -trees.not.present]
trees50.circle <- setRownames(trees50.circle, 3:1)
trees50.circle <- filterRows(trees50.circle)
names(trees50.circle)[4:ncol(trees50.circle)] <-
c('ac', 'bp', 'cb', 'fx', 'lx', 'ps', 'pt', 'q', 'rp', 'tc')
rstudio::viewData(trees50.circle)
rstudio::viewData(trees50.circle)
trees50 <- read.table('podil_drevin.csv', sep='\t', head=T)
trees50 <- trees50[, seq_len(ncol(trees50)-4)]
trees50[is.na(trees50)] <- 0
trees50.circle <- aggregate(trees50[, -(1:4)],
list(trees50$opakovani, trees50$treatment, trees50$plocha),
function(x) {
round(sum(x[1:4]) / (50 * 4 * 4) * pi * 50^2) + x[5]
})
# remove non-present trees
trees.not.present <- which(colSums(trees50.circle[, 4:ncol(trees50.circle)]) == 0) + 3
trees50.circle <- trees50.circle[, -trees.not.present]
trees50.circle <- setRownames(trees50.circle, 3:1)
trees50.circle <- filterRows(trees50.circle)
names(trees50.circle)[4:ncol(trees50.circle)] <-
c('ac', 'bp', 'cb', 'fx', 'lx', 'ps', 'pt', 'q', 'rp', 'tc')
rstudio::viewData(trees50.circle)
rowSums(trees50.circle[trees.circle$treatment=='C', 4:13])
rowSums(trees50.circle[trees50.circle$treatment=='C', 4:13])
mean(rowSums(trees50.circle[trees50.circle$treatment=='C', 4:13]))
rstudio::viewData(landscape.trees)
rstudio::viewData(landscape.trees)
rstudio::viewData(landscape)
landscape <- landscape[, 1:5]
rstudio::viewData(landscape)
landscape <- cbind(landscape[, 1:5], landscape.trees)
rstudio::viewData(landscape)
getwd()
write.table(landscape, file='landscape0.csv', sep='\t')
setwd('/media/Data/Dropbox/skola/dipl/data/gis/')
rstudio::viewData(landscape)
segments.data <- read.table('../csv/primary/landscape1.csv', sep='\t')
rstudio::viewData(segments.data)
segments.data$veg
seg.veg <- segments.data$veg[segments.data$veg!='']
seg.veg
420/(pi*2500)
420/(pi*50^2)
426/(pi*50^2)
fix(segments.polygons)
segments.polygons
segments.polygons[1:5]
segments.polygons[1:5,]
segments.polygons@data[1:5,]
plot(segments.polygons[1,], add=T, col='yellow')
350^2
350*390
359*388
359*400
359*405
segments.polygons <- readOGR(".", layer="segmentsPolygons")
segments.points <- readOGR(".", layer="segmentsPoints")
segments.polygons$id <- over(segments.polygons, segments.points)$id
segments.polygons@data[1:5,]
order(segments.polygons$id)
segments.polygons$id[order(segments.polygons$id)]
segments.polygons <- segments.polygons$[order(segments.polygons$id), ]
segments.polygons <- segments.polygons[order(segments.polygons$id), ]
plot(segments.polygons, col=1:5)
grey(.5)
grey(c(.5, .8))
plot(segments.polygons, col=grey(seq(0, 1, length.out=nrow(segments.polygons))))
segments.data <- read.table('../csv/primary/landscape1.csv', sep='\t')
rstudio::viewData(segments.data)
segments.data.ratio <- segments.data[segments.data$count.type=='ratio']
segments.data.ratio <- segments.data[segments.data$count.type=='ratio', ]
segments.data.count <- segments.data[segments.data$count.type=='count', ]
rstudio::viewData(segments.data.ratio)
rstudio::viewData(segments.data.count)
str(segments.data)
segments.data.ratio <- segments.data[segments.data$count.type=='ratio', 6:ncol(segments.data)]
segments.data.count <- segments.data[segments.data$count.type=='count', 6:ncol(segments.data)]
rstudio::viewData(segments.data.count)
rstudio::viewData(segments.data.ratio)
rstudio::viewData(segments.data.count)
rstudio::viewData(segments.data)
data.frame('x', 'y')
segments.data[1,]
class(segments.data[1,])
data.frame(rbind('x', 'y')
)
rbind(data.frame('x', 1), data.frame('y', 2))
rbind(data.frame('x', 1), data.frame('x', 1))
empty.seg <- segments.data[1:2, ]
rstudio::viewData(empty.seg)
segments.factors <- segments.data$factor[segments.data$count.type='ratio']
segments.factors <- segments.data$factor[segments.data$count.type=='ratio']
fix(segments.factors)
x <- matrix(1:25, 5 ,5)
x
x * rep(2,5)
x*2
x * matrix(rep(2,5))
matrix(rep(2,5))
x * t(matrix(rep(2,5)))
y <- matrix(c(rep(0,20), rep(1,5)), 5 ,5)
y
x+y
x
MyMatrix <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol=3, byrow=TRUE)
MyMatrix
x
vec <- 1:5
x *vec
x
x *t(vec)
t(t(x) *t)
t(t(x)*t)
t(x)
t(x)*t
t(t(x)*vec)
x
t(x)
x*vec
?sweep
segments.trees.counts <-
segments.data.ratio * segments.polygons$area[seq_len(segments.data.ratio)] * 426 / (pi * 50^2)
segments.trees.counts <-
segments.data.ratio * segments.polygons$area[seq_len(nrow(segments.data.ratio))] * 426 / (pi * 50^2)
rstudio::viewData(segments.trees.counts)
segments.trees.counts <-
segments.data.ratio * segments.polygons$area[seq_len(nrow(segments.data.ratio))] *
segments.factors * 426 / (pi * 50^2)
rstudio::viewData(segments.trees.counts)
segments.trees.counts <-
(segments.data.ratio * segments.polygons$area[seq_len(nrow(segments.data.ratio))] *
segments.factors * 426 / (pi * 50^2)) + segments.data.count
rstudio::viewData(segments.trees.counts)
segments.trees.counts <- cbind(segments.data[segments.data$count.type=='ratio', 1:5],
segments.trees.counts)
rstudio::viewData(segments.trees.counts)
nrow(segments.polygons)
empty.seg <- segments.trees.counts[1, ]
rstudio::viewData(empty.seg)
empty.seg
empty.seg <- segments.trees.counts[seq_len(nrow(segments.polygons) - nrow(segments.trees.counts)), ]
empty.seg$segment <- nrow(segments.trees.counts) + seq_len(nrow(empty.seg))
rstudio::viewData(empty.seg)
empty.seg$veg <- rep(0, nrow(empty.seg))
rstudio::viewData(empty.seg)
empty.seg$remark <- rep('', nrow(empty.seg))
empty.seg[seq_len(nrow(empty.seg)), 6:ncol(empty.seg)] <- 0
rstudio::viewData(empty.seg)
segments.trees.counts <- rbind(segments.trees.counts, empty.seg)
rstudio::viewData(segments.trees.counts)
empty.seg$factor <- rep(0, nrow(empty.seg))
segments.trees.counts <-
(segments.data.ratio * segments.polygons$area[seq_len(nrow(segments.data.ratio))] *
segments.factors * 426 / (pi * 50^2)) + segments.data.count
segments.trees.counts <- cbind(segments.data[segments.data$count.type=='ratio', 1:5],
segments.trees.counts)
empty.seg <- segments.trees.counts[seq_len(nrow(segments.polygons) - nrow(segments.trees.counts)), ]
empty.seg$segment <- nrow(segments.trees.counts) + seq_len(nrow(empty.seg))
empty.seg$veg <- rep(0, nrow(empty.seg))
empty.seg$factor <- rep(0, nrow(empty.seg))
empty.seg$remark <- rep('', nrow(empty.seg))
empty.seg[seq_len(nrow(empty.seg)), 6:ncol(empty.seg)] <- 0
segments.trees.counts <- rbind(segments.trees.counts, empty.seg)
rstudio::viewData(segments.trees.counts)
segments.polygons@data
segments.polygons@data <- cbind(segments.polygons@data, segments.trees.counts)
segments.polygons@data
segments.polygons$id <- segments.polygons$segment
plot(segments.polygons, col=segments.polygons$veg)
names(segments.polygons)
plot(segments.polygons, col=grey(segments.polygons$q/rowSums(segments.polygons[, 9:34]))
plot(segments.polygons, col=grey(segments.polygons$q/rowSums(segments.polygons[, 9:34])))
plot(segments.polygons, col=grey(segments.polygons$q/rowSums(segments.polygons@data[, 9:34])))
segments.polygons$q
rowSums(segments.polygons@data[, 9:34])
segments.polygons$q/rowSums(segments.polygons@data[, 9:34])
ratio
ratio <- segments.polygons$q/rowSums(segments.polygons@data[, 9:34])
ratio[is.na(ratio)] <- 0
plot(segments.polygons, col=grey(ratio))
plot(segments.polygons, col=grey(1-ratio))
ratio <- segments.polygons$bp/rowSums(segments.polygons@data[, 9:34])
ratio[is.na(ratio)] <- 0
plot(segments.polygons, col=grey(1-ratio))
ratio <- segments.polygons$rp/rowSums(segments.polygons@data[, 9:34])
ratio[is.na(ratio)] <- 0
plot(segments.polygons, col=grey(1-ratio))
ratio <- segments.polygons$cb/rowSums(segments.polygons@data[, 9:34])
ratio[is.na(ratio)] <- 0
plot(segments.polygons, col=grey(1-ratio))
getwd()
writeOGR(segments.polygons, "../gis/", "segmentsTrees", "ESRI Shapefile")
plot(segments.polygons, col=grey(segments.polygons$cb>0))
plot(segments.polygons, col=grey(!segments.polygons$cb>0))
plot(segments.polygons, col=grey(!segments.polygons$pnig>0))
writeOGR(segments.polygons, "../gis/", "segmentsTrees", "ESRI Shapefile")
