[R-sig-Geo] Map2Poly: Error message

Roger Bivand Roger.Bivand at nhh.no
Wed Aug 9 20:34:14 CEST 2006


On Wed, 9 Aug 2006, Graham Cookson wrote:

> 
> 
> Dear Roger (...and the list)
> 
> Thank you Roger for that useful insight. I have tried your suggestion and,
> once again, encountered some error messages. I've played around with it a
> little bit, but I'm getting nowhere.
> 
> Perhaps you will have come across this problem before.
> 
> I tried your routine so I typed:
> 
> library(foreign)
> library(maptools)
> library(spdep)
> map<-readShapePoly("englandandwales.shp")
> 
> But I got the following error:
> 
> Error in if (rD < 0) hole <- TRUE : missing value where TRUE/FALSE needed
> 
> Following the various examples in the help file I then tried
> 
> map<-readShapePoly("englandandwales.shp", IDvar="LABEL")
> 
> But now get the following error:
> 
> Error in from [j]: to [j]: NA/NaN argument
> 
> Error in coordinates(coords): unable to find the argument 'obj' in selecting
> a method for function 'coordinates'
> 
> 
> I've got this feeling I'm just doing something really silly but can't work
> it out. Any help welcome. It may help to know that all I want to do is
> produce a proximity matrix of contiguous boundary neighbours from the
> Shapefile for now.
> 
> 
> Again, I'm using R2.2.0 on an Apple iBook G4. The shapefile is a merged file
> of England and Wales ward boundaries downloaded from Edina.ac.uk and was
> merged in ArcView. It contains some 8,500 polygons and is 250MB.

Graham,

There is almost certainly something wrong with the shapefile, and the only 
way to debug this is either for you to do it, or for you to make the file 
available for the maptools package maintainer (me) to do it. It's too 
large to email, you may not want to post it on an open website, so maybe 
copy it to a CDROM and send it by post?

We know that firms like Geolytics sell shapefiles breaking the ESRI
specification, and I would not be surprised if this is also the case.

In my original reply 

https://stat.ethz.ch/pipermail/r-sig-geo/2006-August/001214.html

I suggested that you should include sessionInfo() and traceback()  
information. Since you have not done this, we don't know which version of
maptools you are using, not what the call context of the error messages 
actually was. Since you are on OSX, you could install the rgdal
package from source (if you can do that, involving installing GDAL and 
PROJ.4 too, try readOGR() in that package). 

What we need to dig out is first which shape is throwing the error, and
then what value is present that leads to the error. This will involve
using debug() on the private functions I named before and trying to read
your data (or similar data with the same error).

Can other software read the file? 

Roger

> 
> Thank you,
> Graham
> 
> 
> 

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