我试图找到一种在现有投影网格中绘制地图的好方法(137x108网格点)。我发现库字段和as.image-image.plot非常简单直接,但我对显示框的分辨率并不完全满意。我尝试更改nrow
和ncol
,但在我的地图中出现临界值(100+)后出现白色间隙。我在下面提供一个示例,您将需要netcdf4
库来读取该文件。
欢迎任何建议或替代方法。
#Elevation data can be downloaded in the following link,
#http://www.ecad.eu/download/ensembles/data/Grid_0.44deg_rot/elev_0.44deg_rot_v9.0.nc.gz
#INSTALLING-LOADING NECESSARY LIBRARIES
install.packages(fields)
install.packages(ncdf)
library(fields)
library(ncdf)
#READING FILES
orog.nc <- open.ncdf("elev_0.44deg_rot_v9.0.nc")
orog <- get.var.ncdf( orog.nc, "elevation")
orog[orog <= -99]=NA
x <- get.var.ncdf( orog.nc, "Actual_longitude")
y <- get.var.ncdf( orog.nc, "Actual_latitude")
xy <- data.frame(lon=c(x),lat=c(y))
set.panel(1,3)
#PLOTING LOW RES
look <- as.image(c(orog), x=xy, na.rm=T)
image.plot(look, col=terrain.colors(100))
world( add=TRUE)
#PLOTING "HIGH RES"
look <- as.image(c(orog), x=xy, na.rm=T, nrow=100, ncol=100)
image.plot(look, col=terrain.colors(100))
world( add=TRUE)
#PLOTING TOO "HIGH RES"
look <- as.image(c(orog), x=xy, na.rm=T, nrow=150, ncol=150)
image.plot(look, col=terrain.colors(100))
world( add=TRUE)
根据蒂姆里夫的建设性意见, 事实上,你的数据分辨率更高(例如0.22deg - 272x214)你可以在代码中设置更多的nrow和ncol,而不会出现白色网格点效应问题。还有一个问题,如何定义nrow-ncol阈值?
#Install Libraries and read data as the previous post,
#but instead download 0.22deg file for fine resolution.
#http://www.ecad.eu/download/ensembles/data/Grid_0.22deg_rot/elev_0.22deg_rot_v9.0.nc.gz
set.panel(1,2)
#PLOTING "LOW RES"
look <- as.image(c(orog), x=xy, na.rm=T)
image.plot(look, col=terrain.colors(100))
world( add=TRUE)
#PLOTING "HIGH RES"
look <- as.image(c(orog), x=xy, na.rm=T, nrow=175, ncol=175)
image.plot(look, col=terrain.colors(100))
world( add=TRUE)