library(mapview, quietly = T)
library(sf, quietly = T)
## Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
library(tidycensus, quietly = T)
library(tidyverse, quietly = T)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.6 v dplyr 1.0.7
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(sf, quietly = T)
library(tmap, quietly = T)
library(dplyr, quietly = T)
library(tmap, quietly = T)
library(ggplot2, quietly = T)
library(classInt, quietly = T)
library(patchwork, quietly = T)
library(tmaptools, quietly = T)
library(ggsn, quietly = T)
library(censusxy, quietly = T)
library(sysfonts, quietly = T)
library(readr)
addr <- read_csv("C:/Users/spara/OneDrive/Desktop/wic&gstore.csv")
## New names:
## * Source -> Source...1
## * Source -> Source...227
## * `` -> ...228
## 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...
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
addr <- addr[c(6, 12:14)]
names(addr) <- c("street", "city", "st", "zip")
head(addr)
library(censusxy)
results<-cxy_geocode(addr,
street = "street",
city = "city",
state ="st",
zip = "zip",
class="sf",
output = "simple")
## 25 rows removed to create an sf object. These were addresses that the geocoder could not match.
mapview::mapview(results, layer="WIC Services & Grocery Stores")
library(sf)
st_write(results, dsn="`/.", layer="WIC Services & Grocery Stores", driver="ESRI Shapefile", delete_layer = T, update = T)
## Warning: 'update' is deprecated.
## Use 'append' instead.
## See help("Deprecated")
## Deleting layer `WIC Services & Grocery Stores' using driver `ESRI Shapefile'
## Updating layer `WIC Services & Grocery Stores' to data source ``/.' using driver `ESRI Shapefile'
## Writing 33 features with 4 fields and geometry type Point.
57% of the locations are geocoded.
add <- read.csv("C:/Users/spara/OneDrive/Desktop/wic&gstore.csv")
add <- add[c(6, 12:14)]
names(add) <- c("street", "city", "st", "zip")
head(add)
library(censusxy)
results<-cxy_geocode(addr,
street = "street",
city = "city",
state ="st",
zip = "zip",
class="sf",
output = "simple")
## 25 rows removed to create an sf object. These were addresses that the geocoder could not match.
mapview::mapview(results, layer="Grocery Stores")
library(sf)
st_write(results, dsn="`/.", layer="Grocery Stores", driver="ESRI Shapefile", delete_layer = T, update = T)
## Warning: 'update' is deprecated.
## Use 'append' instead.
## See help("Deprecated")
## Deleting layer `Grocery Stores' using driver `ESRI Shapefile'
## Updating layer `Grocery Stores' to data source ``/.' using driver `ESRI Shapefile'
## Writing 33 features with 4 fields and geometry type Point.
53% of the locations are geocoded.
add <- read.csv("C:/Users/spara/OneDrive/Desktop/wic&gstore.csv")
add <- add[c(6, 12:14)]
names(add) <- c("street", "city", "st", "zip")
head(add)
library(censusxy)
results<-cxy_geocode(addr,
street = "street",
city = "city",
state ="st",
zip = "zip",
class="sf",
output = "simple")
## 24 rows removed to create an sf object. These were addresses that the geocoder could not match.
mapview::mapview(results, layer="WIC Services")
library(sf)
st_write(results, dsn="`/.", layer="WIC Services", driver="ESRI Shapefile", delete_layer = T, update = T)
## Warning: 'update' is deprecated.
## Use 'append' instead.
## See help("Deprecated")
## Deleting layer `WIC Services' using driver `ESRI Shapefile'
## Updating layer `WIC Services' to data source ``/.' using driver `ESRI Shapefile'
## Writing 34 features with 4 fields and geometry type Point.
52% of the locations are geocoded.