I want to plot sea surface temperature data from a regular grid but can't find the proper way to do it. My data comes in nc format and can be downloaded from http://www.nodc.noaa.gov/SatelliteData/pathfinder4km/
I use this R code to access data but the problem appears when trying to plot
library("ncdf")
download.file("ftp://ftp.nodc.noaa.gov/pub/data.nodc/pathfinder/Version5.2/2003/20030715000715-NODC-L3C_GHRSST-SSTskin-AVHRR_Pathfinder-PFV5.2_NOAA17_G_2003196_night-v02.0-fv02.0.nc", destfile="sst.nc")
data=open.ncdf("sst.nc")
x <- get.var.ncdf(data,"lon")
y <- get.var.ncdf(data,"lat")
sst=get.var.ncdf(data,"sea_surface_temperature")
filled.contour(x,y,sst, color = terrain.colors, asp = 1)
And then get this error message
Error en filled.contour(x, y, sst, color = terrain.colors, asp = 1) : increasing 'x' and 'y' values expected
I think the problem comes from y coordinate, latitude runs from 90 to -90. I've seen some questions on stackoverflow in creating a new grid with akima package but it should not be necessary in this case.
Here you can find a summary of data file
http://ubuntuone.com/1mIdYVqoePn24gKQbtXy7K
Thanks in advance for your help
SOLVED
Thanks to Paul Hiemstra
The point was not read lat-lon values from data set but to know the i,j coordinates of data points in the matrix and then select the geographic area I want to plot. Following are the commands that work for me:
library("ncdf")
download.file("ftp://ftp.nodc.noaa.gov/pub/data.nodc/pathfinder/Version5.2/2003/20030715000715-NODC-L3C_GHRSST-SSTskin-AVHRR_Pathfinder-PFV5.2_NOAA17_G_2003196_night-v02.0-fv02.0.nc", destfile="sst.nc")
data=open.ncdf("sst.nc")
sst=get.var.ncdf(data,"sea_surface_temperature")
x = seq(1, 8640, length.out = nrow(sst)) # Matrix dimension 8640x4320
y = seq(1, 4320, length.out = ncol(sst))
sst1 <- sst[c(1000:1500),c(1000:1500)] # Subsetting a region
x = seq(1, 500, length.out = nrow(sst1))
y = seq(1, 500, length.out = ncol(sst1))
png(filename="sst.png",width=800,height=600,bg="white")
filled.contour(x,y,sst1, color = terrain.colors, asp = 1)
dev.off()
Now I have to figure out how to label the plot with longtiude and latitude at x-y coordinates.