[R-sig-Geo] Problem with polygon holes and islands

Ian Reeve ireeve at une.edu.au
Sat Mar 5 12:00:34 CET 2011


Dear all,

I'm importing census tract boundaries into R from a government website where the boundaries are provided as Mapinfo Interchange Format files, using:

mypolygons <- readOGR("websitefile.mif", layer="websitefile")

Some census tracts have holes.  In these cases, the hole slot of the outer polygon is TRUE and the hole slot of the inner polygon is FALSE.  I have to reverse these manually to get these tracts to plot correctly.

Some census tracts comprise a collection of islands.  In these cases, the hole slot of the first polygon in the collection is FALSE, and in the remainder of the polygons in the collection it is TRUE.  

Again I can correct these manually (and tediously), but I'm wondering if there is either a way of preventing this happening when importing the .mif file, or a single method that can be applied to a SpatialPolygons object to fix the problems in one go.

Any leads much appreciated.

Ian Reeve
University of New England
Armidale, NSW



More information about the R-sig-Geo mailing list