Skip to content
Prev 11103 / 29559 Next

sample.Polygons fails for shapes with more than four Polygons

On Mon, 7 Mar 2011, Aman Verma wrote:

            
Hi Aman,

Thanks for a clear analysis and sample data! Bug fix committed to R-Forge 
SVN, will be in tomorrow's R-Forge builds (revision 1039). If you need it 
earlier, please make an anonymous checkout.

pts <- spsample(shapefile, n=5000, type="random")

now works.
The change adding this code on 16 July 2010 was made to try to improve 
hole logic. Quite often, imported multipolygon objects (Polygons objects 
in sp) have wrong hole status assigned to the geometries. If 
checkPolygonsHoles() in the maptools package has not been run to clean 
them up, this may lead to grief. The code is a guess at finding conditions 
that would identify a hole even though it is declared as not a hole. It 
isn't bullet-proof, and did contain a bug, which you identified.

Best wishes,

Roger