[R] assign point values as labels in spplot

emorway emorway at engr.colostate.edu
Thu Jan 29 21:07:25 CET 2009


In the code to follow, I'm trying to label points with their corresponding
values but have been unsuccessful after many variations to the following
code.  The code below creates the plot I want, I simply cannot get the black
points ("+") to display the actual value.  I'm guessing the problem is
somewhere in the second to last line of code (starts with "pts<-...").  I
have attached the two text files needed to run the code.  
http://www.nabble.com/file/p21734824/R_Hk_Krig_File_Log.txt
R_Hk_Krig_File_Log.txt 
http://www.nabble.com/file/p21734824/Predict_Location_XY.txt
Predict_Location_XY.txt 
Eric

library(gstat)

K.dat<-read.table("C:/temp/R_Hk_Krig_File_Log.txt", header = TRUE)
my.dat<-data.frame(K.dat)
attach(my.dat)
coordinates(my.dat)=~X+Y

pred.dat<-read.table("C:/temp/Predict_Location_XY.txt", header = FALSE)
names(pred.dat)<-c("x","y","p")
my.pred.dat<-data.frame(pred.dat)
coordinates(my.pred.dat)<-~x+y
gridded(my.pred.dat) = TRUE

#Set up 2 exponential variograms
lzm.vgm.exp.noNug<-vgm(1.1,"Exp",2000,0)
lzm.vgm.exp.Nug<-vgm(0.7,"Exp",3000,0.4)

#Krige the exponential variograms
lzm.krig.exp.noNug<-krige(Kh_Log10~1,my.dat,my.pred.dat,model=lzm.vgm.exp.noNug)
lzm.krig.exp.Nug<-krige(Kh_Log10~1,my.dat,my.pred.dat,model=lzm.vgm.exp.Nug)

lzm.krig.exp.noNug$var1.pred<-10^lzm.krig.exp.noNug$var1.pred
lzm.krig.exp.Nug$var1.pred<-10^lzm.krig.exp.Nug$var1.pred

library(sp)
library(lattice)
pts<-list("sp.points",K.dat,pch=3,col="black",labels=as.character(K.dat$Kh))
spplot(lzm.krig.exp.Nug["var1.pred"], scales=list(draw=TRUE), 
	xlab="Easting",ylab="Northing",cuts=25,key.space="right",cex=1.1,
	col.regions=terrain.colors(25),main="Hydraulic Conductivity of Layer 2",
	sp.layout=list(pts))

-- 
View this message in context: http://www.nabble.com/assign-point-values-as-labels-in-spplot-tp21734824p21734824.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list