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@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
signature.asc
Description: OpenPGP digital signature
_______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo