[R] random location in polygons sp spsample splancs csr
Patrick Giraudoux
patrick.giraudoux at univ-fcomte.fr
Sun Feb 17 17:36:02 CET 2008
Dear all,
I had to place points at random, one in each of larger number of
polygons (actually in objects of class 'SpatialPolygonsDataFrame' , see
sp library), and tried first to do it using spsample (from sp).
Surprisingly, every 5-15 trials, the output was a NULL value. The doc
says that ' this may occur when trying to hit a small and awkwardly
shaped polygon in a large bounding box with a small number of points',
but in my case, the shapes were not really awkward, and the bounding box
just the smallest rectangle including the shape, just the number of
points was 1 in each polygon.
Thus I tried csr (from splancs) after having extracted the polygon
coordinates of each shape from the Spatial object, and everything went
smoothly, with hit success every trial.
Has anybody (anybody will probably be Edzer or/and Roger...) an idea why
here splancs looks like outperforming spsample ?
Patrick
More information about the R-help
mailing list