Skip to content
Back to formatted view

Raw Message

Message-ID: <CAHMizkPYCE70GWeD9xVMtSR4Qn2z2Aj9Cj3roTy9rKm=5k=VVQ@mail.gmail.com>
Date: 2016-05-11T12:51:53Z
From: Juta Kawalerowicz
Subject: spsample bug?

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]]