c173c273_lec17_w11[1]

# c173c273_lec17_w11[1] - University of California Los...

This preview shows pages 1–10. Sign up to view the full content.

University of California, Los Angeles Department of Statistics Statistics C173/C273 Instructor: Nicolas Christou Assign \NA values outside the area de

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
ned by the observed data points In this document we will discuss how to assign \NA values to the area of the raster map outside the observed data points. We should always try to keep the predictions within the region de
ned by the data points. Kriging is an interpolator not extrapolator. We will use again the data from the Maas river at a <-read.table("http://www.stat.ucla.edu/~nchristo/statistics_c173_c273/ soil.txt", header=T) # Save the original image function: image.orig <-image We have also saved the original image function since we will work with the gstat package. The following commands have been discussed in

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
previous documents as well. #Create the grid: x.range <-as.integer(range(a[,1])) y.range <-as.integer(range(a[,2])) grd <-expand.grid(x=seq(from=x.range[1], to=x.range[2], by=50), y=seq(from=y.range[1], to=y.range[2], by=50)) #Create a gstat object: g <-gstat(id="log_lead", formula = log(lead)~1, locations = ~x+y, data =a) plot(variogram(g)) #Fit the variogram: v.fit <-fit.variogram(variogram(g), vgm(0.5,"Sph",1000,0.1)) plot(variogram(g),v.fit) #Perform ordinary kriging predictions: pr_ok <-krige(id="log_lead",log(lead)~1, locations=~x+y,model=v.fit, data=a, newdata=grd) #Collapse the vector of
the predicted values into a matrix: qqq <-matrix(pr_ok\$log_lead.pred, length(seq(from=x.range[1], to=x.range[2], by=50)), length(seq(from=y.range[1], to=y.range[2], by=50))) #Create a raster map: image.orig(seq(from=x.range[1], to=x.range[2], by=50), seq(from=y.range[1],to=y.range[2], by=50), qqq, xlab="West to East",ylab="South to North", main="Predicted values") 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
#Add the observed data points on the raster map: points(a) Thecommandsabovewillcreatetherastermap: 179000179500180000180500181000330000331000332000333000Predicted valuesWest to EastSouth to North l ll l l l ll l l l l l l l l l l l llll l l ll l l l l l l l ll l l l l l ll l l l l l l l l l l l l l
l l l l l l l l l l l l l l ll ll ll l l l l l l l l l l l l l l ll l l l l ll l l l l l l l l l l l ll l l ll l l l l l ll l l l l l

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
l l l l l l l l l l ll l ll l l l ll l l l l ll l l We would like now to keep only the part of the raster map which is de
ned by the observed data points. We

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/11/2012 for the course STATS c173/c273 taught by Professor Nicolaschristou during the Spring '11 term at UCLA.

### Page1 / 40

c173c273_lec17_w11[1] - University of California Los...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online