Partition coordinates into quantile polygons
See also
Other Parallelization:
par_grid()
,
par_grid_mirai()
,
par_hierarchy()
,
par_hierarchy_mirai()
,
par_make_grid()
,
par_merge_grid()
,
par_multirasters()
,
par_multirasters_mirai()
,
par_pad_balanced()
,
par_pad_grid()
,
par_split_list()
Examples
if (FALSE) { # \dontrun{
library(terra)
random_points <-
data.frame(x = runif(1000, 0, 100), y = runif(1000, 0, 100))
quantiles <- seq(0, 1, length.out = 5L)
qpoly <- par_cut_coords(random_points$x, random_points$y, quantiles)
clustered_points <-
data.frame(x = rgamma(1000, 1, 1), y = rgamma(1000, 4, 1))
qpoly_c <- par_cut_coords(clustered_points$x, clustered_points$y, quantiles)
par(mfcol = c(1, 2))
plot(qpoly)
plot(qpoly_c)
par(mfcol = c(1, 1))
cvect <- terra::vect(clustered_points, geom = c("x", "y"))
plot(cvect)
plot(qpoly_c, add = TRUE, col = "transparent", border = "red")
qcv <- intersect(cvect, qpoly_c)
table(qcv$CGRIDID)
sum(table(qcv$CGRIDID)) # should be 1000
} # }