6.5 Spatial Distance Plot

# xy-plot with spatial distance (Cu NiZap)
library(StatDA)

# need also this package:
library(sgeostat)

data(moss)
data(kola.background)

X=moss[,"XCOO"]
Y=moss[,"YCOO"]
Cu=moss[,"Cu"]

loc = list(x=c(766824.2,755182.3,708614.7,667868.0,354991.9,353536.7,592195.7),
y=c(7751607,7679137,7635654,7611937,7614572,7908407,7903136))

loc.in=in.polygon(X,Y,loc$x,loc$y) # observations in polygone

ref=c(616307.2, 7716277) # reference point


pdf("fig-6-9.pdf",width=9,height=4.5)
par(mfrow=c(1,2),mar=c(4,4,2,2))

plotbg(map.col=c("gray","gray","gray","gray"), xlab="UTM east [m]", ylab="UTM north [m]",
cex.lab=1.2)

points(X[!loc.in],Y[!loc.in],pch=16,cex=0.3)
points(X[loc.in],Y[loc.in],pch=3,cex=0.7)
points(ref[1],ref[2],pch=16,cex=1)
polygon(loc$x,loc$y,border=1,lwd=1.3)


distanc=sqrt((X[loc.in]-ref[1])^2+(Y[loc.in]-ref[2])^2)

plot(distanc/1000,log10(Cu[loc.in]),xlab="Distance to Nikel/Zapoljarnij [km]",
ylab="Cu in Moss [mg/kg]", yaxt="n", pch=3,cex=0.7, cex.lab=1.2)
axis(2,at=log10(a<-sort(c((10^(-50:50))%*%t(c(2,5,10))))),labels=a)
lines(smooth.spline(distanc/1000,log10(Cu[loc.in]),spar=0.8),col=1,lwd=1.3)

dev.off()
# Fig. 6.10.: xy-plot with spatial distance (Cu NiZap-Monch)
library(StatDA)

# need also this package:
library(sgeostat)

data(moss)
data(kola.background)
X=moss[,"XCOO"]
Y=moss[,"YCOO"]
Cu=moss[,"Cu"]

loc = list(x=c(590565.1,511872.8,779702.8,861156.3),
y=c(7824652,7769344,7428054,7510341))

loc.in=in.polygon(X,Y,loc$x,loc$y) # observations in polygone

ref=c(542245.3,7803068) # reference point

pdf("fig-6-10.pdf",width=9,height=4.5)

par(mfrow=c(1,2),mar=c(4,4,2,2))

plotbg(map.col=c("gray","gray","gray","gray"), xlab="UTM east [m]", ylab="UTM north [m]",
cex.lab=1.2)
points(X[!loc.in],Y[!loc.in],pch=16,cex=0.3)
points(X[loc.in],Y[loc.in],pch=3,cex=0.7)
points(ref[1],ref[2],pch=16,cex=1)
polygon(loc$x,loc$y,border=1,lwd=1.3)


distanc=sqrt((X[loc.in]-ref[1])^2+(Y[loc.in]-ref[2])^2)

plot(distanc/1000,log10(Cu[loc.in]),xlab="Distance from reference point [km]",
ylab="Cu in Moss [mg/kg]", yaxt="n", pch=3,cex=0.7, cex.lab=1.2)
axis(2,at=log10(a<-sort(c((10^(-50:50))%*%t(c(2,5,10))))),labels=a)
lines(smooth.spline(distanc/1000,log10(Cu[loc.in]),spar=0.8),col=1,lwd=1.3)

dev.off()