[R] How to create a "nb" object?

Roger Bivand Roger.Bivand at nhh.no
Thu Feb 19 13:20:18 CET 2004

On Thu, 19 Feb 2004, René Eschen wrote:

> Hi group,
> I'd like to do spatial analysis of my data using the spdep package. It
> appears that a file of class nb is necessary, but I do not find what
> that should look like and if there is a function that creates such file
> for me.

If you have points that represent your data observations, you can use
triangulation-based functions like: tri2nb, gabrielneigh, relativeneigh,
soi.graph, graph2nb; distance-based neighbours from dnearneigh; k-nearest
neighbours from knn2nb and knearneigh. If you have polygons, you can find
contiguous polygons with poly2nb;  and cell2nb will give you an nb object
for a regular grid.

Which you choose will depend on your research problem and how your data 
are structured. Some can generate observations with no neighbours 
(especially the distance-based schemes). You can also export neighbour 
lists in "GAL" format from programs like GeoDa for use in spdep in R.


> How can I create a nb-object of my data points?
> Thanks,
> René Eschen.
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Roger Bivand
Econonic Geography Section, Department of Economics, Norwegian School of 
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, 
Norway, voice: +47-55959355, fax: +47-55959393; Roger.Bivand at nhh.no

More information about the R-help mailing list