[R-sig-Geo] spsample and small sample size
patrick.giraudoux at univ-fcomte.fr
Mon Oct 20 11:38:28 CEST 2008
I met a trouble with spsample which has been solved by Roger Bivand off
list. I though it was general enough to be of interest for other users.
In brief I needed to get 50 random points on a SpatialLinesDataFrame
called "hydntline" and got:
Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "coordinates", for
Roger's response is the following:
The reason is that some lines are assigned no sample points, and the
function tries to create a SpatialPoints object with no points. The
workaround is to increase n, then reduce the output by sampling back down.
z <- spsample(hydntline,4000,type="random")
zz <- z[sample(nrow(coordinates(z)), 50)]
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 399 bytes
Desc: not available
More information about the R-sig-Geo