[R-sig-Geo] Errors while creating a neighbourhood matrix using poly2nb
Roger Bivand
Roger.Bivand at nhh.no
Tue Mar 25 10:29:38 CET 2008
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
>
> Does anyone recognize these problems or has a solution for me?
>
> Thanks,
> Oscar
> ____________________________________________________________________________
>
> DISCLAIMER: http://www.rivm.nl/disclaimer.htm\ ...{{dropped:2}}
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> 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