fld2df.Rd
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)
fld | Vector of ngrid=nlat*nlon values: a single time slice of the field. |
---|---|
griddata | The griddata structure returned from
|
ti | The time index. The time variable in the output will be set to
|
fldts | Matrix [ntime, ngrid] of spatial fields |
Data frame with variables lat, lon, value, and optionally t.
In addition to reformatting the data as a data frame, these functions remap 0-360 longitude to -180, 180.