gridmat: Generate a Grid on the Sphere

View source: R/gridmat.R

gridmatR Documentation

Generate a Grid on the Sphere

Description

Generates a grid on the sphere, or a spherical cap, band, wedge, or quadrangle.

Usage

gridmat(colats, lons, ncolat=100, nlon=100, cellarea=FALSE)

Arguments

colats

A length 2 numeric, giving the minimum and maximum colatitudes to be included in the grid (in that order)

lons

A length 2 numeric, giving the minimum and maximum longitudes to be included in the grid (in that order)

ncolat

Optional. The number of rows in the grid (each row corresponding to a circle of colatitude).

nlon

Optional. The number of columns in the grid (each row corresponding to a semicircle of longitude).

cellarea

Print the area of the cells in a third column of the output matrix.

Details

This function generates a grid on the sphere, or a spherical cap, band, wedge, or quadrangle. The cells in the grid have equal area and width (measured in angular distance); the cosines of the heights of the cells are also equal. The output is the centres of all the grid cells, which can be used in calculations e.g.~estimation of the distribution of the distance from a randomly selected point in a window to the nearst point in a spatial point pattern. Finer grids (i.e. high values of ncolats, nlons) heighten the accuracy of such estimates but can take a long time for R to generate those estimates.

Note that the shape of the cells is dependent on the values of the input variables. Ideally, the cells should be close to square (i.e.~[cos(colats[2])-cos(colats[1])]/ncolats and (lons[2]-lons[1])/nlons should be (close to) equal.)

For a spherical cap or band, set lons=c(0, 2*pi) and colats as appropriate; for a spherical wedge, set colats=c(0, pi) and lons as appropriate. For the entire sphere, set colats=c(0, pi), lons=(0, 2*pi).

As the output is in spherical coordinates, the radius of the sphere is not required. Correctly invoking convert3 on the result of gridmat gives the locations of the centres of the cells on the sphere of desired radius, in Cartesian coordinates

The function rot.sphere can be used to rotate the grid if required.

Value

A 2 column matrix giving the locations of all points in the grid, in spherical coordinates. The points are ordered by colatitude, then longitude - both in ascending order.

Author(s)

Tom Lawrence <email: tjlawrence@bigpond.com>

Examples

gridsph <- gridmat(colats=c(0, pi), lons=c(0, 2*pi), ncolat=100, nlon=100)

baddstats/spherstat documentation built on Feb. 6, 2023, 1:45 a.m.