[R-sig-Geo] Errors while creating a neighbourhood matrix using poly2nb

Roger Bivand Roger.Bivand at nhh.no
Tue Mar 25 11:08:43 CET 2008


On Tue, 25 Mar 2008, Oscar Breugelmans wrote:

> Thanks Roger,
> Changing the snap distance already did the trick. I didn't know Arcmap was
> so inaccurate!

Well, maybe it is assuming that centimetres don't matter at your scale? 
Not so unreasonable, but hard for computers to grasp? "Vector is correcter 
..." only for an assumed correctness? Something like the thickness of my 
pen point?

Roger



> Oscar
>
>
>
>
>             Roger Bivand
>             <Roger.Bivand at nhh
>             .no>                                                       To
>             Sent by:                  Oscar Breugelmans
>             r-sig-geo-bounces         <Oscar.Breugelmans at rivm.nl>
>             @stat.math.ethz.c                                          cc
>             h                         r-sig-geo at stat.math.ethz.ch
>                                                                   Subject
>                                       Re: [R-sig-Geo] Errors while
>             25-03-2008 10:29          creating a neighbourhood matrix
>                                       using poly2nb
>
>             Please respond to
>             Roger.Bivand at nhh.
>                    no
>
>
>
>
>
>
> On Tue, 25 Mar 2008, Oscar Breugelmans wrote:
>
>> Hi everybody,
>>
>> I am trying to create a neigbourhood matrix based on a shapefile of
> postal
>> code areas that was created in ArcMap. Normally this works fine using the
>> 'readShapePoly' and 'poly2nb' commands. However, the postal code areas
>> change over the years or are made up of 2 or mory polygons because they
> are
>> situated on both sides of a large waterway. I correct these difficulties
> by
>> merging postal code areas in ArcMap, so that I end up with a shapefile in
>> which each postal code area is represented by just 1 polygon with an
> unique
>> area ID.
>> I again import the updated shapefile in R using readShapePoly. But then
> the
>> problems start. When I create a neighbourhood matrix using poly2nb, the
>> areas that have been merged behave very strange: they don't recognize
> their
>> neighbours. Sometimes they recognize none, sometimes a few.
>> When I couldn't find a solution I tried to create the nb using GeoDa.
> This
>> gave exactly the same problems. Then I turned to GeoBugs and - surprise -
>> the nb was created without any problems.
>
> Almost certainly a topologically unclean set of boundaries. If you do the
> merging in R using unionSpatialPolygons() in maptools, the output
> SpatialPolygons ought to be OK. Use the post codes as the ID union key,
> and they will be used beith as the Polygons objects IDs, and the region.id
> values of the neighbour list. You could also try increasing the snap
> distance in poly2nb(), as this may relieve problems of remaining slivers.
>
> Hope this helps,
>
> Roger
>
>
>
>
>
>
>
>
>

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