Function for random points selection from grid cells in a spatial object

declstr_random(spatial_object, cellsize, numpoints)

Arguments

spatial_object

Object of class sfc or sf

cellsize

Target cellsize in map units

numpoints

Number of points that will be chosen from a grid cell

Value

Object of class sf

Examples

points4 = sf::st_read(system.file("points/punkty4.shp", package = "declusteringr"))
#> Reading layer `punkty4' from data source `C:\Users\Lenovo\AppData\Local\Temp\RtmpgxlZS1\temp_libpath1b4c671b41b4\declusteringr\points\punkty4.shp' using driver `ESRI Shapefile' #> Simple feature collection with 200 features and 1 field #> geometry type: POINT #> dimension: XY #> bbox: xmin: -1775590 ymin: -5316527 xmax: -1642585 ymax: -5237789 #> epsg (SRID): NA #> proj4string: +proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +units=m +no_defs
x = declstr_random(spatial_object = points4, cellsize = 10000, numpoints = 2) x
#> Simple feature collection with 159 features and 1 field #> geometry type: POINT #> dimension: XY #> bbox: xmin: -1774543 ymin: -5316527 xmax: -1642585 ymax: -5237789 #> epsg (SRID): NA #> proj4string: +proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +units=m +no_defs #> First 10 features: #> id geometry #> 50 49 POINT (-1757793 -5311478) #> 68 67 POINT (-1764673 -5310663) #> 177 176 POINT (-1748461 -5307808) #> 4 3 POINT (-1748079 -5310699) #> 56 55 POINT (-1745143 -5315420) #> 64 63 POINT (-1733773 -5308707) #> 16 15 POINT (-1725205 -5311317) #> 28 27 POINT (-1708887 -5310775) #> 59 58 POINT (-1705916 -5313721) #> 195 194 POINT (-1698034 -5316527)