Learn R Programming

ExceedanceTools (version 1.2.0)

create.pgrid2: Create grid of locations.

Description

create.pgrid2 creates a grid of locations fusing vectors of x and y coordinates.

Usage

create.pgrid2(xgrid, ygrid, midpoints = FALSE, poly.coords = NULL)

Arguments

xgrid
A vector of locations in the x direction.
ygrid
A vector of location in the y direction.
midpoints
A logical value (TRUE or FALSE) indicating whether the boundary values are for the midpoint of a pixel (midpoints = TRUE) or for the boundary of the spatial domain in general (midpoints = FALSE, in which
poly.coords
An $n \times 2$ matrix with the coordinates specifying the polygon vertices of the true spatial domain of interest within the rectangular boundaries provided by xmin, xmax, ymin, and ymax. If this is pro

Value

  • Returns an object of class pgrid with the following components:
  • pgridAn $n \times 2$ matrix of locations (the midpoints of the pixelized grid).
  • mThe number of rows in pgrid.
  • p.in.gridA vector of 0s and 1s indicating whether the midpoint of each pixel is in the convex hull of poly.coords. If poly.coords is not provided, this is a vector of 1s.
  • ubxThe pixel boundaries in the x-direction.
  • ubyThe pixel boundaries in the y-direction.
  • upxThe pixel midpoints in the x-direction.
  • upyThe pixel midpoints in the y-direction.

Details

The key argument in the function midpoints. If this is TRUE, it is assumed that the boundaries of the spatial domain correspond to the midpoints of the cell/pixel in the grid. Otherwise, it is assumed that the boundaries correspond to the actual borders of the region of interest. If poly.coords is supplied, the grid returned is the grid of midpoints contained in the convex hull of poly.coords.

Examples

Run this code
seq1 = seq(0, 1, len = 101)
pgrida <- create.pgrid2(seq1, seq1, midpoint = FALSE)
seq2 = seq(.005, .995, len = 100)
pgridb <- create.pgrid2(seq2, seq2, midpoint = TRUE)
# pgrids produced match
range(pgrida$pgrid - pgridb$pgrid)

Run the code above in your browser using DataLab