1

我想用R画出sst(海面温度),但还是有一些错误,作为一个新的,请告诉我问题出在哪里

rr.txt 的格式如下

  89 rows  180 cols means 2*2 grid data

ee<-read.table("C:\\Users\\topmad\\Desktop\\New folder\\rr.txt")
ee
dim(ee)
long<-seq(0,360,2)
lati<-seq(0,180,2)
m<-c(91:180, 1:90)
m
length(m)

require(maps)
maps::map(database="world", fill=TRUE, col="light blue")
maps::map.axes()
contour(long,lati,ee[,m], add=TRUE)
par(ask=TRUE)
4

1 回答 1

3

你的问题是你的尺寸。

#Let's create some random values:
ee<-array(rnorm(89*180),dim=c(89,180))

#If ee has 89 rows (corresponding to latitude I guess) then lati needs 89 values:
lati <- seq(-90,90,length=89) #Latitudes goes from -90 to 90 as far as I know :)
#Same thing with columns/longitude:
long <- seq(-180,180,length=180)

#you probably want your contour behind the continents so first an empty plot:
plot(NA, xlim=c(-180,180), ylim=c(-90,90), xlab="", ylab="", xaxs="i", yaxs="i")
#Then your contour (you need to transpose ee so that rows are longitudes):
contour(long, lati, t(ee), add=TRUE)
# And then your continents:
maps::map(database="world", fill=TRUE, col="light blue", add=TRUE)

在此处输入图像描述

于 2013-03-22T08:04:45.077 回答