PBSmapping (version 2.69.76)

makeGrid: Make a Grid of Polygons

Description

Make a grid of polygons, using PIDs and SIDs according to the input arguments.

Usage

makeGrid(x,y,byrow=TRUE,addSID=TRUE,projection=NULL,zone=NULL)

Arguments

x

vector of X-coordinates (of length \(m\)).

y

vector of Y-coordinates (of length \(n\)).

byrow

Boolean value; if TRUE, increment PID along X.

addSID

Boolean value; if TRUE, include an SID column in the resulting PolySet.

projection

optional projection attribute to add to the PolySet.

zone

optional zone attribute to add to the PolySet.

Value

PolySet with columns PID, SID (if addSID = TRUE), POS, X, and Y. The PolySet is a set of rectangular grid cells with vertices: \((x_{i}, y_{j}), (x_{i+1}, y_{j}), (x_{i+1}, y_{j+1}), (x_{i}, y_{j+1})\).

Details

This function makes a grid of polygons, labeling them according to byrow and addSID. In the following description, the variables \(i\) and \(j\) indicate column and row numbers, respectively, where the lower-left cell of the grid is (1, 1).

  • byrow \(=\) TRUE and addSID \(=\) FALSE implies PID \(= i + (j - 1) \times (m - 1)\)

  • byrow \(=\) FALSE and addSID \(=\) FALSE implies PID \(= j + (i - 1) \times (n - 1)\)

  • byrow \(=\) TRUE and addSID \(=\) TRUE implies PID \(= i\), SID \(= j\)

  • byrow \(=\) FALSE and addSID \(=\) TRUE implies PID \(= j\), SID \(= i\)

See Also

addPolys, clipPolys, combineEvents, findCells, findPolys, PolySet, thickenPolys.

Examples

Run this code
local(envir=.PBSmapEnv,expr={
  oldpar = par(no.readonly=TRUE)
  #--- make a 10 x 10 grid
  polyGrid <- makeGrid(x=0:10, y=0:10)
  #--- plot the grid
  plotPolys(polyGrid, density=0, projection=1)
  par(oldpar)
})

Run the code above in your browser using DataLab