crds,GRaster-method | R Documentation |
Returns the coordinates of the center of cells of a GRaster
or coordinates of a GVector
's vertices. The output will be a matrix
, data.frame
, or list
. If you want the output to be a "points" GVector
, use as.points()
.
## S4 method for signature 'GRaster'
crds(x, z = is.3d(x), na.rm = TRUE)
## S4 method for signature 'GVector'
crds(x, z = is.3d(x))
st_coordinates(x)
x |
A |
z |
If |
na.rm |
Logical: If |
A matrix
, data.frame
, or list
.
terra::crds()
if (grassStarted()) {
# Setup
library(terra)
# Plant specimens (points), elevation (raster)
madDypsis <- fastData("madDypsis")
madElev <- fastData("madElev")
# Convert a SpatRaster to a GRaster, and sf to a GVector
dypsis <- fast(madDypsis)
elev <- fast(madElev)
### Get coordinates:
dypsisPoints <- crds(dypsis)
elevPoints <- crds(elev)
head(dypsisPoints)
head(elevPoints)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.