getLandingsFromTarget {roads} | R Documentation |
Get landing points inside harvest blocks
Description
Generate landing points inside polygons representing harvested area. There
are three different sampling types available: "centroid" is the default and
will return the centroid or a point that is inside the polygon if the
centroid is not (see st_point_on_surface
); "random" takes a
random sample based on the given landingDens
see
(st_sample
); "regular" intersects the polygons with a
regular grid with cell size sqrt(1/landingDens)
, if a polygon does not
intersect with the grid its centroid is used.
Usage
getLandingsFromTarget(harvest, landingDens = NULL, sampleType = "centroid")
Arguments
harvest |
sf, SpatialPolygons or RasterLayer object with harvested areas. If it is a RasterLayer with more than one unique value other than 0 each value will be run separately which will produce different results from a 0/1 raster but will be much slower. |
landingDens |
number of landings per unit area. This should be in the same units as the CRS of the harvest. Note that 0.001 points per m2 is > 1000 points per km2 so this number is usually very small for projected CRS. |
sampleType |
character. "centroid" (default), "regular" or "random".
Centroid returns one landing per harvest block, which is guaranteed to be
in the harvest block for sf objects but not for rasters. Regular returns
points from a grid with density |
Details
Note that the landingDens
is in points per unit area where the unit of
area is determined by the CRS. For projected CRS this should likely be a very
small number i.e. < 0.001.
Value
an sf simple feature collection with an ID column and POINT geometry
Examples
doPlots <- interactive()
demoScen <- prepExData(demoScen)
polys <- demoScen[[1]]$landings.poly[1:2,]
# Get centroid
outCent <- getLandingsFromTarget(polys)
if(doPlots){
plot(sf::st_geometry(polys))
plot(outCent, col = "red", add = TRUE)
}
# Get random sample with density 0.1 points per unit area
outRand <- getLandingsFromTarget(polys, 0.1, sampleType = "random")
if(doPlots){
plot(sf::st_geometry(polys))
plot(outRand, col = "red", add = TRUE)
}
# Get regular sample with density 0.1 points per unit area
outReg <- getLandingsFromTarget(polys, 0.1, sampleType = "regular")
if(doPlots){
plot(sf::st_geometry(polys))
plot(outReg, col = "red", add = TRUE)
}