make.grid | R Documentation |
Create a grd object from x
, y
and z
data.
For use with draw.grid
and write.grid
.
make.grid(x, y, z, byx , byy , xlim, ylim, fun = function(x) sum(x, na.rm = T))
x |
a vector of x-coordinates (longitude) |
y |
a vector of y-coordinates (latitude; same length as |
z |
a vector of values; same length as |
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 |
fun |
a function to be applied to |
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.
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.
Hans Gerritsen
draw.grid
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.