View source: R/elimCellDuplicates.r
elimCellDuplicates | R Documentation |
This function thins spatial points such that no more than one point falls within each cell of a reference raster. If more than one point falls in a cell, the first point in the input data is retained unless the user specifies a priority for keeping points.
elimCellDuplicates(x, rast, longLat = NULL, priority = NULL)
x |
Points. This can be either a |
rast |
|
longLat |
Two-element character vector or two-element integer vector. If |
priority |
Either |
Object of class x
.
# This example can take >10 second to run.
library(terra)
x <- data.frame(
long=c(-90.1, -90.1, -90.2, 20),
lat=c(38, 38, 38, 38), point=letters[1:4]
)
rast <- rast() # empty raster covering entire world with 1-degree resolution
elimCellDuplicates(x, rast, longLat=c(1, 2))
elimCellDuplicates(x, rast, longLat=c(1, 2), priority=c(3, 2, 1, 0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.