Generate longitude and latitude grid matrices

Share:

Description

grid2D is a helper function that generates longitude and latitude rectangular mesh from short longitude and latitude vectors in gridded data.

Usage

1

Arguments

lon

a vector of longitudes with length N. Longitudes takes values from -180 to 180 (not 0 to 360). For gridded data, the length may have the value (n) provided that n * m = N where n = length(unique(lon)) and m = length(unique(lat)).

lat

a vector of latitudes with length N or m. See lon.

Details

grid2D function convert the long latitude and longitude vectors to a rectangular two-dimensional grid for visualization and geographic masking purposes for gridded data in HiClimR package.

Value

A list with the following components:

lon

an (n rows by m columns) matrix of 'double' values for longitude mesh grid, or a vector with length n * m.

lat

an (n rows by m columns) matrix of 'double' values for latitude mesh grid, or a vector with length n * m.

Author(s)

Hamada Badr <badr@jhu.edu>, Ben Zaitchik <zaitchik@jhu.edu>, and Amin Dezfuli <dez@jhu.edu>.

References

Hamada S. Badr, Zaitchik, B. F. and Dezfuli, A. K. (2015): A Tool for Hierarchical Climate Regionalization, Earth Science Informatics, 1-10, http://dx.doi.org/10.1007/s12145-015-0221-7.

Hamada S. Badr, Zaitchik, B. F. and Dezfuli, A. K. (2014): Hierarchical Climate Regionalization, CRAN, http://cran.r-project.org/package=HiClimR.

See Also

HiClimR, validClimR, geogMask, coarseR, fastCor, grid2D, and minSigCor.

Examples

1
2
3
4
5
6
7
8
9
require(HiClimR)

## Load test case data
x <- TestCase$x

## Generate longitude and latitude mesh vectors
xGrid <- grid2D(lon = unique(TestCase$lon), lat = unique(TestCase$lat))
lon <- c(xGrid$lon)
lat <- c(xGrid$lat)