1

I want to draw the sst(sea surface temperature) with R,but there is still with some error in the line ,as a new ,please tell me where the problem is

the rr.txt is formated like this

  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)
thelatemail
  • 91,185
  • 12
  • 128
  • 188
TOPMAD
  • 621
  • 2
  • 8
  • 14
  • 3
    We don't have your data nor what the result looks like, nor we know what the expected result should look like. Please make your work reproducible, or, give out more information (like an image of the result). Help us so we can help you. – Roman Luštrik Mar 22 '13 at 07:13
  • sorry ,my mother tone is not english ,so there must be some mistake the pic I want to draw is like this http://stackoverflow.com/questions/9172247/r-contour-map i can't understand the meaning of contour in map how to arrange the data? – TOPMAD Mar 22 '13 at 07:37

1 Answers1

3

Your issue is with your dimensions.

#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)

enter image description here

plannapus
  • 18,529
  • 4
  • 72
  • 94