Skip to content

Instantly share code, notes, and snippets.

@datagistips
Created August 10, 2012 15:29
Show Gist options
  • Save datagistips/3315054 to your computer and use it in GitHub Desktop.
Save datagistips/3315054 to your computer and use it in GitHub Desktop.
Sextante QGIS - R script for analysing neighbord relationships below a certain distance threshold
##[datagistips]=group
##polygons=vector
##distance=number 10
##output=output vector
library("spdep")
nb = poly2nb(polygons, snap=distance)
polygons[["nNeigh"]] = card(nb)
polygons[["neighGroup"]] = n.comp.nb(nb)[["comp.id"]]
output = polygons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment