Hi there, in this brief tutorial I will show you how to create a lisa map from scratch in R… For some reason the p-values in R and the p-values computed in Geoda for the local Moran’s I are slightly different. Any questions (or suggestions in order to improve this tutorial) are always welcome! Regards, Felipe.

1 loading required packages

## -- Attaching packages --------
## v ggplot2 3.3.0     v purrr   0.3.4
## v tibble  3.0.1     v dplyr   0.8.5
## v tidyr   1.0.3     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.5.0
## -- Conflicts -----------------
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
## Loading required package: spData
## To access larger datasets in this package, install the spDataLarge
## package with: `install.packages('spDataLarge',
## repos='https://nowosad.github.io/drat/', type='source')`
## rgeos version: 0.5-3, (SVN revision 634)
##  GEOS runtime version: 3.8.0-CAPI-1.13.1 
##  Linking to sp version: 1.4-1 
##  Polygon checking: TRUE
## 
## Attaching package: 'rgeoda'
## The following object is masked from 'package:spdep':
## 
##     skater

2 Import the different shapefiles for Pakistan

## Reading layer `gadm36_PAK_0' from data source `C:\Users\felip\OneDrive\Desktop\Meidai\Seminar Research\GitHub\tutorial-local-morans-I-spatial-scales\shapefiles\gadm36_PAK_0.shp' using driver `ESRI Shapefile'
## Simple feature collection with 1 feature and 2 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 60.89944 ymin: 23.70292 xmax: 77.84308 ymax: 37.09701
## geographic CRS: WGS 84
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"
## Reading layer `gadm36_PAK_1' from data source `C:\Users\felip\OneDrive\Desktop\Meidai\Seminar Research\GitHub\tutorial-local-morans-I-spatial-scales\shapefiles\gadm36_PAK_1.shp' using driver `ESRI Shapefile'
## Simple feature collection with 8 features and 10 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 60.89944 ymin: 23.70292 xmax: 77.84308 ymax: 37.09701
## geographic CRS: WGS 84
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"
## Reading layer `gadm36_PAK_2noNA' from data source `C:\Users\felip\OneDrive\Desktop\Meidai\Seminar Research\GitHub\tutorial-local-morans-I-spatial-scales\shapefiles\gadm36_PAK_2noNA.shp' using driver `ESRI Shapefile'
## Simple feature collection with 29 features and 14 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 60.89944 ymin: 23.70292 xmax: 75.367 ymax: 36.8898
## geographic CRS: WGS 84
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"
## Reading layer `gadm36_PAK_3_noNA' from data source `C:\Users\felip\OneDrive\Desktop\Meidai\Seminar Research\GitHub\tutorial-local-morans-I-spatial-scales\shapefiles\gadm36_PAK_3_noNA.shp' using driver `ESRI Shapefile'
## Simple feature collection with 116 features and 21 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 60.89944 ymin: 23.70292 xmax: 75.367 ymax: 36.8898
## geographic CRS: WGS 84
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"

quick-maps