View source: R/point_in_cell.R
point_in_cell | R Documentation |
This function examines which points fall within a raster cell with data (not NA). Returns TRUE for points falling in a raster cell with data, and FALSE otherwise.
point_in_cell(locs = NULL, ras = NULL, layer = 1)
locs |
An |
ras |
|
layer |
Integer. Raster layer to use for comparing with point locations (default = 1). |
A logical vector.
locs <- data.frame(lon = c(1, 2, 1, 2), lat = c(1, 1, 2, 3))
locs.sf <- locs2sf(locs)
library(terra)
ras <- rast(nrows = 2, ncols = 2, xmin = 0.5, xmax = 3.5, ymin = 0.5, ymax = 3.5,
resolution = 1, vals = c(NA, 1, 1, NA, NA, 1, NA, 1, 1))
occmap(locs.sf, ras, pcol = "black", psize = 3)
point_in_cell(locs.sf, ras)
# adding column to original point data
locs.sf$inras <- point_in_cell(locs.sf, ras)
locs.sf
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.