【发布时间】:2016-07-16 16:12:03
【问题描述】:
我有一个名为“seoul032823”的 81 次观测的每小时 PM10 数据集。您可以从Here 下载。我已经在这个数据集上执行了普通的克里金法,还得到了用于克里金法预测的空间图。我还可以在国家地图上显示观察数据点。但是我不能在国家地图上重叠克里金空间预测图。
我想做什么:我想将我的空间预测地图重叠在韩国地图(不是整个韩国)上。我感兴趣的区域是纬度 37.2N 到 37.7N 和经度 126.6E 到 127.2E。这意味着我需要从韩国地图上裁剪这个区域并将预测地图重叠在上面。我还需要显示原始观测数据点,这些数据点将根据浓度值跟随空间图的颜色。 例如,我想要这种类型的地图:
我的克里金 R 代码,并在韩国地图上显示数据点:
library(sp)
library(gstat)
library(automap)
library(rgdal)
library(e1071)
library(dplyr)
library(lattice)
seoul032823 <- read.csv ("seoul032823.csv")
#plotting the pm10 data on Korea Map
library(ggplot2)
library(raster)
seoul032823 <- read.csv ("seoul032823.csv")
skorea<- getData("GADM", country= "KOR", level=1)
plot(skorea)
skorea<- fortify(skorea)
ggplot()+
geom_map(data= skorea, map= skorea, aes(x=long,y=lat,map_id=id,group=group),
fill=NA, colour="black") +
geom_point(data=seoul032823, aes(x=LON, y=LAT),
colour= "red", alpha=0.7,na.rm=T) +
#scale_size(range=c(2,4))+
labs(title= "PM10 Concentration in Seoul Area at South Korea",
x="Longitude", y= "Latitude", size="PM10(microgm/m3)")+
theme(title= element_text(hjust = 0.5,vjust = 1,face= c("bold")))
# Reprojection
coordinates(seoul032823) <- ~LON+LAT
proj4string(seoul032823) <- "+proj=longlat +datum=WGS84"
seoul032823 <- spTransform(seoul032823, CRS("+proj=utm +north +zone=52 +datum=WGS84"))
#Creating the grid for Kriging
LON.range <- range(as.integer(seoul032823@coords[,1 ])) + c(0,1)
LAT.range <- range(as.integer(seoul032823@coords[,2 ]))
seoul032823.grid <- expand.grid(LON = seq(from = LON.range[1], to = LON.range[2], by = 1500),
LAT = seq(from = LAT.range[1], to = LAT.range[2], by = 1500))
plot(seoul032823.grid)
points(seoul032823, pch= 16,col="red")
coordinates(seoul032823.grid)<- ~LON+LAT
gridded(seoul032823.grid)<- T
plot(seoul032823.grid)
points(seoul032823, pch= 16,col="red")
# kriging spatial prediction map
seoul032823_OK<- autoKrige(formula = PM10~1,input_data = seoul032823, new_data = seoul032823.grid )
pts.s <- list("sp.points", seoul032823, col = "red", pch = 16)
automapPlot(seoul032823_OK$krige_output, "var1.pred", asp = 1,
sp.layout = list(pts.s), main = " Kriging Prediction")
我使用automap 包进行克里金法,ggplot2 用于绘制韩国地图。
【问题讨论】:
-
您提供了赏金但没有奖励?哎呀。 :)
-
真的非常抱歉。我忘了。我接受了你的回答。我应该怎么做才能给你赏金?
-
不用担心。 SO自动奖励一半。无论如何,我希望你解决了你想要的其余外观更改。
-
感谢您的关心。实际上,我正在尝试很多,但我还没有成功。 theme_minimal() 在许多情况下会产生一些问题。顺便说一句,祝你有美好的一天。