GEOG 566

         Advanced spatial statistics and GIScience

May 6, 2017

Forest Structure Assessment Using Variogram in R

Filed under: 2017,Tutorial 1 @ 8:16 am

Question and tool

The questions that I try to answer in tutorial 1 is how the height and crown width vary in space in the study area, whether those variables are autocorrelated. I use variogram analysis in RStudio to answer these questions.

The variogram is defined as the variance of the difference between field values at two locations x and y across realizations of the field (Cressie 1993). The main goal of a variogram analysis is to construct a variogram that best estimates the autocorrelation structure of the underlying stochastic process. Most variograms are defined through several parameters; namely, the nugget effect, sill, and range.

Figure 1. The example of variogram graph

Figure 1. The example of variogram graph

  • Nugget effect represents micro-scale variation or measurement error. It is estimated from the empirical variogram as the value of y(h) for h = 0.
  • Sill representing the variance of the random field.
  • Range is the distance (if any) at which data are no longer autocorrelated.

Data Analysis and Result

The data used in this tutorial is generated from UAV visual images. The UAV visual images were processed through some software. Agisoft photoscan was used to make a 3D point cloud based on the UAV visual images. Then, the 3D point cloud was used in Fusion software to derive forest structure measurements, such as number of trees, height, and canopy width. The result of this data processing is a data set in a table consisting of 804 detected trees with their height and crown width. Unfortunately, because the images were not georeferenced yet, the height in this tutorial is the sum of tree height and elevation.

Figure 2. Detected trees by Fusion software.

In Rstudio, I use the R codes that are stated below to do the variogram analysis. First, I need to install the “gstat” package and load the package using the following R codes:

> install.packages(“gstat”)

> library(gstat)

Next, to load my data into the RStudio, I have to set my working directory. It can be done through the “session” toolbar. The first variogram analysis is for crown width and space (x and y). The R codes used for this first variogram analysis can be seen below. Based on the graph, in general,, crown width is not autocorrelated although there are some patches with different nugget, sill, and range. In the first part of the graph, there is patch with 25 range (distance) which is relatively larger than the other range. I think it can be happened due to different size of crown width in this particular study area. It seems like there are some trees with big crown and some other with smaller crown that are clustered.

> Treelist1<-read.table(“D:/Oregon State University/Term/Spring 2017/GEOG 566/Exercises/Exercise 2/treelist1.csv”, sep=”,”, header=T)

> g1 <- gstat(id = “”, formula =, locations = ~X+Y, +            data = Treelist1)

> plot(variogram(g1))

Figure 3. Variogram graph of crown width

The next variogram analysis is for height and location (x and y). The R codes and graph are shown below. From the graph, it can be seen that the semivariance is incremental with the increase of range (distance). It means that the height is autocorrelated. I think that can happen because of the height data which is the sum of tree height and elevation. Since the elevation is included in the height data, the elevation or the topography of the study area will influence the variance and the variogram analysis.

> g2 <- gstat(id = “Height”, formula = Height~1, locations = ~X+Y, +            data = Treelist1)> plot(variogram(g2))

> plot(variogram(g2))

Figure 4. Variogram graph of height.

My next variogram analysis is the cross variogram analysis. The R codes and graph are given below. It appears that the semivariance of height and crown width is negatively related, which means there is decrease in semivariance when the distance is increased. Cross-variogram values can increase or decrease with distance h depending on the correlation between variable A and variable B. Semi-variogram values, on the other hand, are by definition positive. One thing that is confusing is the negative value of semivariance. In my understanding, the semivariance should have positive value. Maybe there is mistake in my R codes that causes this confusing result.

> g3 <- gstat(g1, id = “Height”, formula = Height~1, locations = ~X+Y, +            data = Treelist1)

> plot(variogram(g3))

Figure 5. Cross variogram graph of crown width and height.

Critique of the method

As explained in the data analysis and result, variogram analysis is useful to assess how the forest structure parameters, such as crown width and height vary in space in the study area, and whether they are autocorrelated or not. In addition, for me, it is faster to do variogram in R using “gstat” package especially when you have data set in table format. I tried using my raster data for variogram analysis in R, but R crashed and there was not enough memory. Therefore, I prefer to use “gstat” and data set in table for variogram analysis. However, variogram analysis in R has limitation in term of visual presentation. It is quite hard to identify which part of the study area that has higher variability (larger patch) since the result is in graph format and not in map.


Print Friendly

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

© 2017 GEOG 566   Powered by WordPress MU    Hosted by