spsample non-random offset
hgerritsen opened this issue · comments
• Both the ‘regular’ and ‘hexagonal’ types do not seem to have proper random offsets; if you sample a large number of times, patterns appear and each location does not have the same probability of being selected.
• In the hexagonal type, some areas inside the spatial object are never selected (This is related to issue #24)
Below is some sample code to illustrate this:
library(sp)
spatial polygon
Sr1 = Polygon(cbind(c(0,1,1,0),c(0,0,1,1)))
Srs1 = Polygons(list(Sr1), "s1")
SpP = SpatialPolygons(list(Srs1))
sample
s <- spsample(SpP, type = "hexagonal", cellsize=0.1)
plot(SpP,axes=T)
plot(s,add=T,pch=1,cex=0.5) # looks fine, but....
sample 250 times
plot(SpP,axes=T)
for(i in 1:250){
s <- spsample(SpP, type = "hexagonal", cellsize=0.1)
plot(s,add=T,pch=16,cex=0.1)
}