I have a large data.frame
which has 3 variables Longitude
, Latitude
and Temp
.
The data is arranged so that it is regularly spaced on a "grid" of 1/4 degree - so that dput(head(dat))
gives:
structure(list(Longitude = c(0.125, 0.375, 0.625, 0.875, 1.125,
1.375), Latitude = c(0.125, 0.125, 0.125, 0.125, 0.125, 0.125
), Temp = c(25.2163, 25.1917, 25.1593, 25.125, 25.0908, 25.0612
)), .Names = c("Longitude", "Latitude", "Temp"), row.names = c(NA,
6L), class = "data.frame").
I am having problems re-arranging it to the required format.
I would like to create a regular surface object (typically a list), where x and y are the grid values and z is a corresponding matrix of the surface. This is the usual format used by persp
, contour
, image
etc.
Using this surface object I will could then be able to easily interpolate to a matrix of locations using interp.surf
from the fields
package.
Any suggestions would be great.