I previously did a cluster analysis on my trees at Mount Washington. I clustered the trees into 3 groups, depending on correlations between growth and climate variables. Below, I create an object for each cluster and then I created layers for slope, aspect, TPI, and TRI (topographic position and roughness indices).
mwaTrees <- read.csv('E:/0Lab_Tyler/wna/TreeRingData/envr.corr.csv')
mwaTrees1 <- mwaTrees$cluster.clim == 1
mwaTrees1 <- mwaTrees[mwaTrees1,]
mwaTrees2 <- mwaTrees$cluster.clim == 2
mwaTrees2 <- mwaTrees[mwaTrees2,]
mwaTrees3 <- mwaTrees$cluster.clim == 3
mwaTrees3 <- mwaTrees[mwaTrees3,]
coordinates(mwaTrees1) <- c("Long", "Lat")
proj4string(mwaTrees1) <- CRS('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0')
coordinates(mwaTrees2) <- c("Long", "Lat")
proj4string(mwaTrees2) <- CRS('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0')
coordinates(mwaTrees3) <- c("Long", "Lat")
proj4string(mwaTrees3) <- CRS('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0')
mwaDEM <- raster('E:/0Lab_Tyler/wna/TreeRingData/mwaDEM.tif')
mwaTemp <- raster('E:/0Lab_Tyler/wna/Layers/mwawna')
mwaContour <- rasterToContour(mwaDEM)
mwaSlope <- terrain(mwaDEM, opt='slope')
mwaAspect <- terrain(mwaDEM, opt='aspect')
mwaTPI <- terrain(mwaDEM, opt='TPI')
mwaTRI <- terrain(mwaDEM, opt='TRI')
Below I plotted my points for trees at Mt. Washington, with a different color for different clusters.
plot(mwaDEM, col=topo.colors(40), xlim=c(-114.321,-114.29), ylim=c(38.9,38.921),
axes=F, box=F, main='Mount Washington')
plot(mwaTrees1, add=T, col='darkgreen')
plot(mwaTrees2, add=T, col='purple')
plot(mwaTrees3, add=T, col='red')
I used ClimateWNA to downscale 4km-resolution PRISM climate data to the resolution of my DEM (10 m). Below, I have mapped my trees on the temperature map from ClimateWNA, with a different color for each cluster.
plot(mwaTemp, col=heat.colors(40), xlim=c(-114.321,-114.29), ylim=c(38.9,38.921),
axes=F, box=F, main='Mount Washington')
plot(mwaContour, add=T, col='grey')
plot(mwaTrees1, add=T, col='darkgreen')
plot(mwaTrees2, add=T, col='purple')
plot(mwaTrees3, add=T, col='blue')
Below I’m just messing around with different ways of displaying my DEM. Using persp() seems like a simple way, but I can’t figure out how to make it so black, because it’s so dense. So right now you can’t see much.
levelplot(mwaDEM, contour=T)
persp(mwaDEM, exp=0.2,phi=35, xlab="Longitude", ylab="Latitude", expand=0.75, zlab="Elevation")
## Warning in persp.default(x = x, y = y, z = value, ...): "exp" is not a
## graphical parameter
plot3D(mwaDEM)
data(meuse)
head(meuse)
## x y cadmium copper lead zinc elev dist om ffreq soil
## 1 181072 333611 11.7 85 299 1022 7.909 0.00135803 13.6 1 1
## 2 181025 333558 8.6 81 277 1141 6.983 0.01222430 14.0 1 1
## 3 181165 333537 6.5 68 199 640 7.800 0.10302900 13.0 1 1
## 4 181298 333484 2.6 81 116 257 7.655 0.19009400 8.0 1 2
## 5 181307 333330 2.8 48 117 269 7.480 0.27709000 8.7 1 2
## 6 181390 333260 3.0 61 137 281 7.791 0.36406700 7.8 1 2
## lime landuse dist.m
## 1 1 Ah 50
## 2 1 Ah 30
## 3 1 Ah 150
## 4 0 Ga 270
## 5 0 Ah 380
## 6 0 Ga 470
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
bubble(meuse, xcol="x",ycol="y",zcol="zinc", maxsize = 2.5, main = "Zinc concentrations")
The semivariograms are plotted below, with the first one including the cloud. They look pretty much the same as cadmium. It seems that the data are spatially autocorrelated to a distance of about 1 km.
ZincVarCloud <- variogram(zinc~1, meuse, cloud = TRUE)
plot(ZincVarCloud,pch=20,cex=1.5,col="black",
ylab=expression("Semivariance ("*gamma*")"),
xlab="Distance (m)",main = "Zinc concentrations")
ZincVar <- variogram(zinc~1, meuse)
plot(ZincVar,pch=20,cex=1.5,col="black",
ylab=expression("Semivariance ("*gamma*")"),
xlab="Distance (m)", main = "Zinc concentrations")
Looks the same for lead, with the sill being around 1 km. Variance dips down as you get further. I have changed cutoff and width in this example.
PbVarCloud <- variogram(lead~1, meuse, cloud = TRUE, cutoff=2000, width=50)
plot(PbVarCloud,pch=20,cex=1.5,col="black",
ylab=expression("Semivariance ("*gamma*")"),
xlab="Distance (m)",main = "Lead concentrations")
PbVar <- variogram(lead~1, meuse, cutoff=2000, width=50)
plot(PbVar,pch=20,cex=1.5,col="black",
ylab=expression("Semivariance ("*gamma*")"),
xlab="Distance (m)", main = "Lead concentrations")
These data revolve around Mary, a woman who lives in the York neighborhood. Mary loves her neighbors, but is feuding with the side of the York neighborhood that’s across Lakeway. She’s fine with everyone else though. She is known throughout the neighborhood for her tuna casseroles that she makes for neighbors. Not many of her neighbors think about their mercury intake, but they should. On the x-axis of the variogram is distance from Mary’s house. She makes more casseroles for her closest neighbors. Mary’s body has very high mercury levels. People who live further from Mary have lower mercury levels, and so there is more variance between their levels and Mary’s levels. The sill occurs around 20 yards from Mary’s house. THANKS MARY
load('E:/0Lab_Tyler/597/mysteryData.Rdata')
coordinates(dat) <- ~x+y
bubble(dat, xcol="x",ycol="y",zcol="z", maxsize = 2.5, main = "Mystery")
MysteryVarCloud <- variogram(z~1, dat, cloud = TRUE, cutoff=2000, width=50)
plot(MysteryVarCloud,pch=20,cex=1.5,col="black",
ylab=expression("Semivariance ("*gamma*")"),
xlab="Distance (yards)",main = "Mystery")
MysteryVar <- variogram(z~1, dat, cutoff=2000, width=2)
plot(MysteryVar,pch=20,cex=1.5,col="black",
ylab=expression("Semivariance ("*gamma*")"),
xlab="Distance (yards)", main = "Mystery")