Problem: We have a sparse array that include some real data. We want to create a contour map for the data. The data set includes x, y, and the measured values.
Solution: I found the following article that provides a complete solution for this problem. Following the link below to read the article.

Software for Exploratory Data Analysis and Statistical Modelling

Then I wrote a R script to create contour map of my measured data.

library(geoR)
temp.df = data.frame(y = mydata$row,
x = mydata$col,
z = mydata$temp)
temp.loess = loess(z ~ x*y, data = temp.df, degree = 2, span = 1)
temp.fit = expand.grid(list(x = seq(1, 16, 0.1), y = seq(1, 4, 0.1)))
z = predict(temp.loess, newdata = temp.fit)
temp.fit$Height = as.numeric(z)

# basic image
image(seq(1, 16, 0.1), seq(1, 4, 0.1), z,
   xlab = "X Coordinate", ylab = "Y Coordinate",
   main = "Surface temp data")
box()

# lattice plot
library(lattice)
levelplot(Height ~ x*y, data = temp.fit,
   xlab = "col", ylab = "row",
   main = "Surface map",
   col.regions = terrain.colors(100)
)
Share

Tags: , , , , ,