Breaking News

R Spatial Data: Read in SHP File

Rate this post

R Spatial Data 1: Read in SHP File

Here we use R and RStudio to read in a spatial data file (as a SHP file), read in a contiguity (GAL) file created in GeoDa, create the same queen contiguity matrix in R and check that the two are the same, and compute a Moran’s I.

Link to Data File:
Link to download R:
Link to Download RStudio:

Here are the commands we used:
NCVACO = readOGR(dsn = “.”, layer = “NCVACO”)“”,$FIPS)
queen.R.nb=poly2nb(NCVACO, row.names=NCVACO$FIPS)
#Rook would be rook.R.nb=poly2nb(NCVACO,queen=FALSE)
#moran(variable, listw, no. regions, sum of weights)
moran(NCVACO$SALESPC,nb2listw(queen.nb), length(NCVACO$SALESPC), Szero(nb2listw(queen.nb)))

Check Also

ABCD GIS OCT 2017 . Tina Cormier

R for Spatial Analysis

R for Spatial Analysis 2.5 ( 2 votes ) R for Spatial Analysis

Leave a Reply

Your email address will not be published. Required fields are marked *