[R-sig-Geo] spsample bug?

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed May 11 17:28:11 CEST 2016



On 11/05/16 14:51, Juta Kawalerowicz wrote:
> 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

did you try enlarging argument iter? For me this worked:

  ...
  points <- spsample(dry.grid.u, n = n, type = "random", iter = 6)

> 
> 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]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Edzer Pebesma
Institute for Geoinformatics  (ifgi),  University of Münster
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/
Spatial Statistics Society http://www.spatialstatistics.info

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20160511/18d33318/attachment.bin>


More information about the R-sig-Geo mailing list