I am doing some work where I need to generate both a) random spatial points b) non-random spatial points, over a polygon i.e. for b) the points probability depends on for example an East-West gradient, or distance from some point source or something else
For a) I can generate random points over a polygon using the spsample()
command in the sp
package as follows:
# Load a spatial polygon from maptools package
library(maptools)
nc <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], proj4string=CRS("+proj=longlat +datum=NAD27"))
plot(nc)
library(sp)
pts <- spsample(nc, 100, type="random")
plot(nc)
points(pts, pch=19, col="red")
This gives exactly what I want for a). But, can this be modified for b) so points are more likely in the East than the West for example ? (and whilst still being able to specify I want 100 points ?)