# make.grid: Create grd object In mapplots: Data Visualisation on Maps

## Description

Create a grd object from `x`, `y` and `z` data. For use with `draw.grid` and `write.grid`.

## Usage

 `1` ```make.grid(x, y, z, byx , byy , xlim, ylim, fun = function(x) sum(x, na.rm = T)) ```

## Arguments

 `x` a vector of x-coordinates (longitude) `y` a vector of y-coordinates (latitude; same length as `x`) `z` a vector of values; same length as `x` `byx, byy` the size of the grid cells on the x and y scale `xlim, ylim` the x and y limits of the grid. Note that the origin of the grid depends on `xlim` and `ylim`, these values will be taken as the mid-point of the bottom-left grid-cell. See example below how to use this to create a grid that matches that of the ICES rectangles. `fun` a function to be applied to `z`. Defaults to `sum`.

## Details

Due to the way fractions are stored in binary format, rounding errors can occur, e.g.:

`as.character(seq(-5,0,by=0.8))`

results in:

`"-5" "-4.2" "-3.4" "-2.6" "-1.8" "-1" "-0.199999999999999"`

this can affect the `make.grid` function although this is generally not a problem.

## Value

a grd object, which is simply a 2-dimensional array with row and column names that correspond to the x and y positions of the grid.

## Author(s)

Hans Gerritsen

`draw.grid`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12``` ```data(coast) data(landings) byx = 1 byy = 0.5 xlim <- c(-15.5,0) ylim <- c(50.25,56) grd <- make.grid(landings\$Lon,landings\$Lat,landings\$LiveWeight, byx, byy, xlim, ylim) breaks <- breaks.grid(grd,zero=FALSE) basemap(xlim, ylim, main = "Gadoid landings") draw.grid(grd,breaks) draw.shape(coast, col="darkgreen") legend.grid("topright", breaks=breaks/1000, type=2, inset=0.02, title="tonnes") ```

### Example output ```
```

mapplots documentation built on May 2, 2019, 9:15 a.m.