[R-sig-Geo] spsample bug?

Juta Kawalerowicz juta.kawalerowicz at nuffield.ox.ac.uk
Wed May 11 14:51:53 CEST 2016


Hi I encountred a problme when running a loop to generate randomly
distributed points within a polygon. The error I get is:

Error in .local(x, n, type, ...) :
iteration did not converge; try enlarging argument iter

Here is the code which allows to get this error (although you will get it
for different i). Any ideas would be much appreciated.

Juta

###import polygon shapefile from Dropbox
con <- url("https://www.dropbox.com/s/b6v2e14dr6rn3zw/spsample.RData?raw=1")
load(con)

#see what's inside
plot(dry.grid.u, col="red", axes=TRUE)
class(dry.grid.u)

#let's say we want 11 points generated
n<-11
#works fine for doing it just once
points<-spsample(dry.grid.u,n=n,type="random")
plot(points, add=TRUE)

#but when looped over many times there is a problem

  for (i in 1:5000){
    print(i)
    points<-spsample(dry.grid.u,n=n,type="random")
  }

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list