makeGrid function

Make a Grid of Polygons

Make a Grid of Polygons

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

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

Arguments

  • x: numeric -- vector of X-coordinates (of length mm).

  • y: numeric -- vector of Y-coordinates (of length nn).

  • byrow: logical -- if TRUE and type='rectangle', increment PID along X (column-wise);

    -- if TRUE and type='hexagon', create flat-topped hexagons contiguous by column and increment PID by column;

    -- if FALSE and type='hexagon', create pointy-topped hexagons contiguous by row and increment PID by row.

  • addSID: logical -- if TRUE, include an SID field in the resulting PolySet , incremented by the alternative dimension used by PID.

  • projection: character -- optional projection attribute to add to the PolySet.

  • zone: numeric -- optional zone attribute to add to the PolySet.

  • type: character -- type of regular tesselation; choices: "rectangle" or "hexagon".

Details

This function makes a grid of polygons, labeling them according to byrow and addSID.

For rectangular tesselations (grid cells), the variables ii and jj

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+(j1)(m1)= i + (j - 1) * (m - 1)

  • byrow == FALSE and addSID ==

    FALSE implies PID =j+(i1)(n1)= j + (i - 1) * (n - 1)

  • byrow == TRUE and addSID ==

    TRUE implies PID =i= i, SID =j= j

  • byrow == FALSE and addSID ==

    TRUE implies PID =j= j, SID =i= i

For hexagonal tesselations (grid cells), ii indicates columns for flat-topped hexagons and rows for pointy-topped hexagons. The reverse is true for jj. Stemming from their six-sided nature, hexagons will adjoin along a long-edge by row when their orientation is such that one vertex is higher than all the others. Hexagons will adjoin along a long-edge by column when their orientation shows two uppermost vertices.

Returns

PolySet with columns PID, SID

(if addSID=TRUE), POS, X, and Y.

The PolySet is a set of rectangular grid cells when type='rectangle', with vertices:

c("(xi,yj),(x(i+1),yj),(x(i+1),y(j+1)),\n(x_i, y_j), (x_(i+1), y_j), (x_(i+1), y_(j+1)),\n", "(xi,y(j+1)) (x_i, y_(j+1))").

The PolySet is a set of hexagonal grid cells when type='hexagon'.

Author(s)

Nicholas M. Boers, Staff Software Engineer

Jobber, Edmonton AB

Rowan Haigh, Program Head -- Offshore Rockfish

Pacific Biological Station (PBS), Fisheries & Oceans Canada (DFO), Nanaimo BC

locus opus: Institute of Ocean Sciences (IOS), Sidney BC

Last modified Rd: 2019-01-04

See Also

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

Examples

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) })