# A tibble: 6 × 4
street city st zip
<chr> <chr> <chr> <dbl>
1 108 King William San Antonio TX 78204
2 905 Nogalitos St San Antonio TX 78204
3 507 Ruiz St San Antonio TX 78207
4 514 W Commerce St San Antonio TX 78207
5 5721 W Commerce St San Antonio TX 78237
6 254 Hobart St San Antonio TX 78237
library(tidycensus)library(dplyr)#load census tract datasa_acs<-get_acs(geography ="tract",state="TX",county ="Bexar", year =2019,variables=c( "DP05_0001E", "DP03_0009P", "DP03_0062E", "DP03_0119PE","DP05_0001E","DP02_0009PE","DP02_0008PE","DP02_0040E","DP02_0038E","DP02_0066PE","DP02_0067PE","DP02_0080PE","DP02_0092PE","DP03_0005PE","DP03_0028PE","DP03_0062E","DP03_0099PE","DP03_0101PE","DP03_0119PE","DP04_0046PE","DP05_0072PE","DP05_0073PE","DP05_0066PE", "DP05_0072PE", "DP02_0113PE") ,geometry = T, output ="wide")
Getting data from the 2015-2019 5-year ACS
Warning: • You have not set a Census API key. Users without a key are limited to 500
queries per day and may experience performance limitations.
ℹ For best results, get a Census API key at
http://api.census.gov/data/key_signup.html and then supply the key to the
`census_api_key()` function to use it throughout your tidycensus session.
This warning is displayed once per session.
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Using the ACS Data Profile
Using the ACS Data Profile
Simple feature collection with 6 features and 12 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 2100089 ymin: 13694870 xmax: 2130647 ymax: 13705940
Projected CRS: NAD83 / Texas South Central (ftUS)
street city st zip GEOID totpop pblack pwhite
2 108 King William San Antonio TX 78204 48029192100 2299 0.7 42.4
23 905 Nogalitos St San Antonio TX 78204 48029150100 5588 0.8 83.1
12 507 Ruiz St San Antonio TX 78207 48029110600 5293 1.1 65.0
14 514 W Commerce St San Antonio TX 78207 48029110100 3160 0.5 52.0
15 5721 W Commerce St San Antonio TX 78237 48029171200 4065 4.6 89.1
9 254 Hobart St San Antonio TX 78237 48029171501 2609 0.0 77.5
phisp punemp medhhinc ppov geometry
2 0.0 3.8 73194 1.2 POINT (2130647 13699644)
23 2.3 7.8 40302 14.5 POINT (2124919 13694869)
12 6.2 16.1 15250 37.8 POINT (2125077 13705944)
14 0.4 2.0 50865 24.7 POINT (2128147 13702613)
15 3.2 4.0 28284 22.3 POINT (2104639 13705051)
9 0.2 6.6 35194 23.6 POINT (2100089 13698413)
mapview(spjoin["ppov"])+mapview(sa_trol)
Nearest Neighborhood Analysis
library(maptools)
Loading required package: sp
Checking rgeos availability: TRUE
Please note that 'maptools' will be retired during 2023,
plan transition at your earliest convenience;
some functionality will be moved to 'sp'.
library(spatstat)
Loading required package: spatstat.data
Loading required package: spatstat.geom
spatstat.geom 3.0-6
Loading required package: spatstat.random
spatstat.random 3.1-3
Loading required package: spatstat.explore
Loading required package: nlme
Attaching package: 'nlme'
The following object is masked from 'package:dplyr':
collapse
spatstat.explore 3.0-6
Loading required package: spatstat.model
Loading required package: rpart
spatstat.model 3.2-1
Loading required package: spatstat.linnet
spatstat.linnet 3.0-6
spatstat 3.0-3
For an introduction to spatstat, type 'beginner'
# library(qgisprocess) #load the package# qgis_configure() #set up QGIS - find the executable# # qgis_algorithms() lists all the available routines in QGIS# head(qgis_algorithms())# algs[grepl(pattern = "nearest", x = algs$algorithm ),]# qgis_show_help("native:nearestneighbouranalysis")# # dr_nn<-qgis_run_algorithm(alg="native:nearestneighbouranalysis",# INPUT=results.proj,# OUTPUT_HTML_FILE=file.path(tempdir(), "wicnn.html"),# load_output = TRUE)# dr_nn
Interpretation
The 0.29 Z score means that within the zip codes 78207, 78204 and 78237 there are is a weak clustering since the score is positive, but very small. The NN_Index gives a score of 1, which according to the literature, anything greater than 1 indicates clustering, but the result of 1.03 is suggesting very weak clustering.