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

Roger Bivand Roger.Bivand at nhh.no
Sat Mar 5 17:19:03 CET 2011

On Sat, 5 Mar 2011, Ian Reeve wrote:

> 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.

If you could make a sample file available, it might be possible to fix. 
The hole slots are being assigned based on the ring direction of the 
polygon boundaries, if the files do not specify the interior or exterior 
status of the ring. This can also be fixed by running checkPolygonsHoles() 
in the maptools package on the list in the polygons slot of the 
SpatialPolygonsDataFrame object, but there may be other possibilities.


> Any leads much appreciated.
> Ian Reeve
> University of New England
> Armidale, NSW
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no

More information about the R-sig-Geo mailing list