[R-sig-Geo] ring not closed - readShapePoly - read.shape - maptools

Susumu Tanimura stanimura-ngs at umin.ac.jp
Fri Feb 9 18:02:11 CET 2007


Hi there,

The same problem happened to me when I used the shape file that is
sold as commercial products.

> getinfo.shape("Phu_Yen_Commune_ll_region.shp")
Shapefile type: Polygon, (5), # of Shapes: 104
> a <- read.shape("Phu_Yen_Commune_ll_region.shp")
Field name:  1__PERS  changed to:  X1__PERS 
Field name:  2_PERS  changed to:  X2_PERS 
Field name:  3_PERS  changed to:  X3_PERS 
       [snip]
Shapefile type: Polygon, (5), # of Shapes: 104
> b <- readShapePoly("Phu_Yen_Commune_ll_region.shp",verbose=TRUE)
Field name:  1__PERS  changed to:  X1__PERS 
Field name:  2_PERS  changed to:  X2_PERS 
Field name:  3_PERS  changed to:  X3_PERS 
       [snip]
Shapefile type: Polygon, (5), # of Shapes: 104
Error in validityMethod(object) : ring not closed

So, read.shape seems to be OK, but readShapePoly does not.  Since
readShapePoly uses internally read.shape and then Map object is passed
to .Map2PolyDF(), I tried to find Map2PolyDF or validityMethod in
source of maptools and sp package.  However, I could not find them.

Dose anybody have better solution?

> OK... after a check, none of the rings are closed... suppose closing was 
> managed automatically by ArcGIS and read.Shape...
> 
> 
> Patrick Giraudoux a écrit :
> > Hi,
> >
> > I have slept on some data of a project which started in 2003 and  just 
> > coming back on them today gives the opportunity to compare read.shape 
> > (shapefiles were initially imported with this function) and 
> > readShapePoly (the new one sp style). The latter will be much more 
> > interesting for the next step, giving directed handling to overlay 
> > methods.
> >
> > Importing one of my shapefile with read.shape ( read as polyshape in 
> > ArcGIS) made (and still makes) no problem. However, when I try to 
> > import it again via readShapePoly, I get this message:
> >
> > > UG<-readShapePoly("U:/Documents and Settings/giraudoux/Mes 
> > documents/FC25/NewSIG050317/UG.shp")
> > Error in validityMethod(object) : ring not closed
> >
> > Clear enough: at least one of the polygons is not closed... which is 
> > confirmed by the fact that I can import the shapefile easy with 
> > readShapeLines. I suppose the readShapePoly is more demanding in 
> > validity control than the older read.Shape and ArcGIS: one cannot 
> > complain for that.
> >
> > I am not afraid of sorting this out with some lines of programme. I 
> > have however a question before writing it: is there already a function 
> > making a check somewhere which could be used to know which one(s) of 
> > the polygons are not closed?
> >
> > Patrick

--
Susumu Tanimura MSc PhD
Dept. of Socio-environmental Medicine
Inst. of Tropical Medicine, Nagasaki University
TEL +81-95-849-7865 FAX +81-95-849-7867
e-mail stanimura-ngs at umin.ac.jp




More information about the R-sig-Geo mailing list