pkern_coords | R Documentation |
Expands a set of y and x grid line numbers in the column-vectorized order returned
by pkern_grid
.
pkern_coords(g, out = "matrix", corner = FALSE, quiet = FALSE)
g |
any object accepted by |
out |
character indicating return value type, either 'list', 'matrix', or 'sf' |
corners |
logical, indicates to only return the corner points |
This is similar to base::expand.grid
but with the first dimension (y) descending
instead of ascending.
out='sf'
returns an sf
simple features object containing points in the same order,
with data (if any) copied from g$gval
into column 'gval'. Note that prod(g$gdim)
points are created, which can be slow for large grids.
a matrix, list, or sf POINT collection, in column vectorized order
gdim = c(5,3)
g_example = pkern_grid(list(gdim=gdim, gres=c(0.5, 0.7), gval=seq(prod(gdim))))
pkern_coords(g_example)
pkern_coords(g_example, out='list')
# corner points
pkern_coords(g_example, corner=TRUE)
pkern_coords(g_example, corner=TRUE, out='list')
# sf output type
if( requireNamespace('sf') ) {
# make the points
sf_coords = pkern_coords(g_example, out='sf')
# data are copied to variable 'gval'
plot(sf_coords, pch=16)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.