fld2df: Reorganize a spatial field into a data frame

Description Usage Arguments Details Value

View source: R/plot.R

Description

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.

Usage

1
2
3
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

Details

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

Value

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


JGCRI/fieldgenr documentation built on July 22, 2020, 3:17 a.m.