[R-sig-Geo] Map2Poly: Error message
graham.cookson at imperial.ac.uk
Wed Aug 9 18:03:11 CEST 2006
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:
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
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.
Centre for Environmental Policy
Imperial College London
4th Floor, RSM Building
Prince Consort Road
London SW7 2BP
Tel: 020 7594 9313
Mob: 07968 061323
Email: graham.cookson at imperial.ac.uk
> From: Roger Bivand <Roger.Bivand at nhh.no>
> Reply-To: Roger.Bivand at nhh.no
> Date: Thu, 3 Aug 2006 19:00:36 +0200 (CEST)
> To: Graham Cookson <graham.cookson at imperial.ac.uk>
> Cc: r-sig-geo at stat.math.ethz.ch
> Subject: Re: [R-sig-Geo] Map2Poly: Error message
> On Thu, 3 Aug 2006, Graham Cookson wrote:
>> Dear List,
>> I hope you can help me with this problem.
>> I am attempting to form an adjacency matrix and I'm trying to get my
>> shapefile into R. However, I get error messages at the initial stages.
>> I used the following code:
>> The map object is created fine and it finds all 8490 polygons, but the
>> Map2poly command generates the following error message:
>> Error in if (res[] > 0) return(as.integer(-1)) else return(as.integer(1))
>> I have searched the web and the R Help Archives but can't find examples of
>> this problem occurring before.
>> The shapefile I am using was created in ArcView by merging the separate
>> Wales and England shapefiles available from UK Borders at Edina.ac.uk
>> I am using R2.2.0 on an Apple iBook G4 running Mac OS X 10.3.9
>> I hope that this isn't a really stupid question
> No, a relevant question on the right list with lots of helpful details.
> The error is thrown in Map2poly -> .get.polylist -> .ringDirxy, where the
> two last functions are internal ones, and the last one, with the error, is
> trying to determine the ring direction.
> This is implemented differently in the readShapePoly() function also in
> maptools, which imports a shapefile into a SpatialPolygonsDataFrame. From
> there, you just coerce to SpatialPolygons to run poly2nb() -
> poly2nb(as(SPDF, "SpatialPolygons")) should work. Could you please try
> that route first, and let us know if it works?
> If you'd prefer not to use the SpatialPolygonsDataFrame class, then we'll
> need to debug the older code, and then access to your shapefile (or a
> subset displaying the same symptoms) will be needed just for testing. In
> any case the output of sessionInfo() and of traceback() immediately after
> the error, together with the full error message would be very useful.
> Setting quiet=FALSE in the Map2poly() call may also show that some
> polygons are getting their ring directions reversed.
> 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