library(readr)
library(data.table)
library(censusxy)
library(mapview)
library(sf)
## Linking to GEOS 3.9.1, GDAL 3.4.3, PROJ 7.2.1; sf_use_s2() is TRUE
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:data.table':
##
## between, first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
wic_west_side <- read_csv("WorkingDirectoryFall2020StatsDem1/gis/wic_west_side.csv")
## New names:
## • `Source` -> `Source...1`
## • `Source` -> `Source...227`
## • `` -> `...228`
## Rows: 104 Columns: 228
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (115): Source...1, Date, Obsolescence Date, Business Name, Legal Name, P...
## dbl (40): Physical Address Number, Physical ZIP, Mailing Address Number, Ma...
## lgl (71): Physical Post Direction, Mailing Post Direction, Importer or Expo...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(wic_west_side)
## # A tibble: 6 × 228
## Source…¹ Date Obsol…² Busin…³ Legal…⁴ Physi…⁵ Physi…⁶ Physi…⁷ Physi…⁸ Physi…⁹
## <chr> <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr>
## 1 AtoZDat… 02/2… 08/23/… Execut… <NA> 419 S … 419 S Main Ave
## 2 AtoZDat… 02/2… 08/23/… Method… <NA> 6700 W… 6700 W Inters… <NA>
## 3 AtoZDat… 02/2… 08/23/… Centra… Centra… 6800 W… 6800 W Inters… <NA>
## 4 AtoZDat… 02/2… 08/23/… Texas … <NA> 527 N … 527 N Leona St
## 5 AtoZDat… 02/2… 08/23/… Commun… <NA> 1410 G… 1410 <NA> Guadal… St
## 6 AtoZDat… 02/2… 08/23/… Boys T… Boys T… 503 Ur… 503 <NA> Urban Loop
## # … with 218 more variables: `Physical Post Direction` <lgl>,
## # `Physical City` <chr>, `Physical State` <chr>, `Physical ZIP` <dbl>,
## # `Physical ZIP 4` <chr>, `Key Executive Name` <chr>, `First Name` <chr>,
## # `Middle Initial` <chr>, `Last Name` <chr>, Title <chr>, Gender <chr>,
## # `Location Employee Size` <dbl>, `Corporate Employee Size` <dbl>,
## # `Revenue / Yr` <chr>, `Mailing Address` <chr>,
## # `Mailing Address Number` <dbl>, `Mailing Pre Direction` <chr>, …
addr<-wic_west_side[c(6, 12:14)]
names(addr)<-c("street", "city", "st", "zip")
head(addr)
## # A tibble: 6 × 4
## street city st zip
## <chr> <chr> <chr> <dbl>
## 1 419 S Main Ave San Antonio TX 78204
## 2 6700 W Interstate 10 San Antonio TX 78201
## 3 6800 W Interstate 10 Ste 200 San Antonio TX 78201
## 4 527 N Leona St San Antonio TX 78207
## 5 1410 Guadalupe St Ste 222 San Antonio TX 78207
## 6 503 Urban Loop San Antonio TX 78204
results<-cxy_geocode(addr,
street = "street",
city = "city",
state ="st",
zip = "zip",
class="sf",
output = "simple")
## 6 rows removed to create an sf object. These were addresses that the geocoder could not match.
## Location of Wic services on the Westside of San Antonio. Basic map by Joshua Reyna. source: AtoZdatabases
library(mapview)
mapview(results, layer.name="WIC Services")
## Westside San Antonio Wic Map By Latitude and Longitude Map by Joshua Reyna : Source AtoZ Databases
addrLL<-read_csv("WorkingDirectoryFall2020StatsDem1/gis/wic_west_side.csv")
## New names:
## Rows: 104 Columns: 228
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (115): Source...1, Date, Obsolescence Date, Business Name, Legal Name, P... dbl
## (40): Physical Address Number, Physical ZIP, Mailing Address Number, Ma... lgl
## (71): Physical Post Direction, Mailing Post Direction, Importer or Expo...
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `Source` -> `Source...1`
## • `Source` -> `Source...227`
## • `` -> `...228`
resultsWIC<-st_as_sf(addrLL, coords=c("Longitude", "Latitude"), crs=4269, agr="constant")
resultsWIC.proj<-st_transform(resultsWIC, crs=2278)
mapview(resultsWIC.proj)
## Westside San Antonio Grocery Store By Latitude and Longitude Map by Joshua Reyna : Source AtoZ Databases
addrLL3<-read_csv("WorkingDirectoryFall2020StatsDem1/gis/grocery_stores.csv")
## New names:
## Rows: 58 Columns: 228
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (170): Source...1, Date, Obsolescence Date, Business Name, Legal Name, P... dbl
## (45): Physical Address Number, Physical ZIP, Physical ZIP 4, Location E... lgl
## (12): Physical Post Direction, Mailing Post Direction, EIN, Importer or...
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `Source` -> `Source...1`
## • `Source` -> `Source...227`
## • `` -> `...228`
resultsGST<-st_as_sf(addrLL3, coords=c("Longitude", "Latitude"), crs=4269, agr="constant")
resultsGST.proj<-st_transform(resultsGST, crs=2278)
mapview(resultsGST.proj)
## Grocery store locations on the Westside of San Antonio. Map by Joshua Reyna. Source:Atozdatabases
addr2<-read_csv("WorkingDirectoryFall2020StatsDem1/gis/grocery_stores.csv")
## New names:
## Rows: 58 Columns: 228
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (170): Source...1, Date, Obsolescence Date, Business Name, Legal Name, P... dbl
## (45): Physical Address Number, Physical ZIP, Physical ZIP 4, Location E... lgl
## (12): Physical Post Direction, Mailing Post Direction, EIN, Importer or...
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `Source` -> `Source...1`
## • `Source` -> `Source...227`
## • `` -> `...228`
addr2<-addr2[c(6, 12:14)]
names(addr2)<-c("street", "city", "st", "zip")
head(addr2)
## # A tibble: 6 × 4
## street city st zip
## <chr> <chr> <chr> <dbl>
## 1 1545 S San Marcos San Antonio TX 78207
## 2 4522 Fredericksburg Rd San Antonio TX 78201
## 3 111 S Leona St San Antonio TX 78207
## 4 4522 Fredericksburg Rd San Antonio TX 78201
## 5 3485 Fredericksburg Rd San Antonio TX 78201
## 6 3309 Hillcrest Dr San Antonio TX 78201
results2<-cxy_geocode(addr2,
street = "street",
city = "city",
state ="st",
zip = "zip",
class="sf",
output = "simple")
## 4 rows removed to create an sf object. These were addresses that the geocoder could not match.
mapview(results2, layer.name="Grocery Store Locations")