The easiest way to plot this sort of data in ggplot is to organize it into a frame with lat, lon, and value columns. To do this you have to replicate the latitude and longitude values as required. These functions convert the matrix representation of fields into a data frame with variables suitable for plotting. fld2df operates on a single time slice, while fldts2df works on an entire time sequence.

fld2df(fld, griddata, ti = NULL)

fldts2df(fldts, griddata)

Arguments

fld

Vector of ngrid=nlat*nlon values: a single time slice of the field.

griddata

The griddata structure returned from read.temperatures.

ti

The time index. The time variable in the output will be set to griddata$time[ti]. If the time index is omitted, then the time variable will be omitted from the output.

fldts

Matrix [ntime, ngrid] of spatial fields

Value

Data frame with variables lat, lon, value, and optionally t.

Details

In addition to reformatting the data as a data frame, these functions remap 0-360 longitude to -180, 180.