0

Rworldmap 看起来正是我绘制气候数据所需要的,但我在将基本地图与气候数据对齐时遇到了问题。我正在绘制的是来自 JAMSTEC 的 2015 年 8 月的海洋温度数据,来自这里:

http://www.jamstec.go.jp/ARGO/argo_web/ancient/MapQ/Mapdataset_e.html

数据集名称为 TS_201508_GLB.nc。我正在使用的 R 脚本如下。国家轮廓很好,但数据仅适用于海洋,数据未显示在海洋中,它以某种方式被抵消。你能告诉我如何将数据与地图对齐吗?

我读过很多文章,但我不知道如何将两者对齐。我拥有的数据是经度和纬度。南纬为负,西经为负,我不明白他们怎么会混淆。地图是如何显示的,纬度/经度是否有某种特殊约定?

感谢您的任何帮助,您可以提供。编码:

library(RNetCDF)
library(sp)
library(rworldmap)
library(rgeos)
library(RColorBrewer)
library (classInt)
library(grid)
library(spam)
library(maps)
library(maptools)
library(fields)
library(methods)
library(rgdal)
library(rworldxtra)

fname <- "G:/Climate_Change/Ocean_Warming/MOAA_GPV_Jamstec_Temperature/TS_201508_GLB.nc"
moaa <- open.nc(fname)
# moaa
print.nc(moaa)
file.inq.nc(moaa)
#TOI is the temperature array extracted from the NCDF file
TOI = var.get.nc(moaa,"TOI",start=c(1,1,1),count=c(360,132,25))
TOI[1,1,1]
Long = var.get.nc(moaa,"LONGITUDE")
Lat = var.get.nc(moaa, "LATITUDE")
Pres = var.get.nc(moaa,"PRES")

# create grid
offset=c(-179.5,-60.50)
cellsize = c(abs(Long[1]-Long[2]),abs(Lat[1]-Lat[2]))
cells.dim = c(dim(Long), dim(Lat))

# create gt
gt <- GridTopology(cellcentre.offset=offset,cellsize=cellsize,cells.dim=cells.dim)

# create map window
mapDevice()
# Create a color pallette
colourPalette=c('blue','lightblue','white',brewer.pal(9,'YlOrRd'))
# Values at 2000 decibar for August 2015
ncMatrix <- TOI[,,25]
# Gridvalues
gridVals <-data.frame(att=as.vector(ncMatrix))

# create a spatialGridDataFrame
sGDF <-SpatialGridDataFrame(gt,data=gridVals)
# Vector to classify data
catMethod=seq(from=0,to=4,by=.33)
# plotting the map and getting params for legend
mapParams <- mapGriddedData( sGDF, nameColumnToPlot='att',catMethod=catMethod,colourPalette=colourPalette,addLegend=FALSE)
4

1 回答 1

0

我终于弄明白了。rworldmap 希望从地图的左上角(西北角)组织数据,即 Long = -180,Lat=90。NetCDF 数据从 Long=0 和 Lat=-90(地图中间和南边)开始。所以我们必须反转南北方向的值:

#
# Flip the Latitude values so south is last
 ncMatrix2 <- ncMatrix[,dim(Lat):1]

然后切换东经和西经的值:

#
#Longitude values need to be from -180 to 0 then 0 to 180
# So we divide into East and West, then recombine with rbind
East_Long_values <-ncMatrix2[1:180,]
West_Long_Values <-ncMatrix2[181:360,]
ncMatrix3 <- rbind(West_Long_Values,East_Long_values)

然后一切正常。

于 2016-05-27T21:19:10.617 回答