Pizza and Beers in Springfield, OR
R Setup
1 Study Area: Springfield Oregon
I selected Springfield, Oregon as my study area. It is a small city
near the City of Eugene and has a population of about 51,700 in 2023 (the City of Springfield,
2024). I used tigris
package to retrieve the
geographical boundary of the city.
spring <- tigris::places('OR', progress_bar = F) %>%
filter(NAME == "Springfield") %>%
st_transform(4326)
spring
:) Simple feature collection with 1 feature and 16 fields
:) Geometry type: MULTIPOLYGON
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44 xmax: -123 ymax: 44.1
:) Geodetic CRS: WGS 84
:) STATEFP PLACEFP PLACENS GEOID NAME NAMELSAD LSAD CLASSFP PCICBSA PCINECTA MTFCC FUNCSTAT ALAND AWATER INTPTLAT INTPTLON geometry
:) 1 41 69600 02411961 4169600 Springfield Springfield city 25 C1 <NA> <NA> G4110 A 41097246 0 +44.0537862 -122.9811343 MULTIPOLYGON (((-123 44, -1...
Maybe erase this part: I don’t know which county belongs to Springfield or which counties constitute the City of Springfield. Referring to the above spatial boundary of Springfield, we can see that Springfield, also as an incorporated place, has a GEOID of 4123850 in the TIGER shapefile database. Using this GEOID, we can narrow down the census tracts that cover the City of Springfield among 1001 census tracts in Oregon.
tract_oregon <- tidycensus::get_acs(geography = "tract", # or "block group", "county", "state" etc.
state = "OR",
variables = c(hhincome = 'B19019_001'),
year = 2021,
survey = "acs5",
geometry = TRUE,
output = "wide") %>%
st_transform(4326)
:) | | | 0% | |======= | 2% | |============== | 3% | |==================== | 4% | |=========================== | 6% | |================================== | 7% | |======================================== | 9% | |=============================================== | 10% | |====================================================== | 11% | |============================================================ | 13% | |=================================================================== | 14% | |========================================================================== | 16% | |================================================================================ | 17% | |======================================================================================= | 18% | |============================================================================================== | 20% | |==================================================================================================== | 21% | |=========================================================================================================== | 23% | |================================================================================================================== | 24% | |======================================================================================================================== | 26% | |=============================================================================================================================== | 27% | |===================================================================================================================================== | 28% | |============================================================================================================================================ | 30% | |=================================================================================================================================================== | 31% | |========================================================================================================================================================= | 33% | |================================================================================================================================================================ | 34% | |======================================================================================================================================================================= | 35% | |============================================================================================================================================================================= | 37% | |==================================================================================================================================================================================== | 38% | |=========================================================================================================================================================================================== | 40% | |================================================================================================================================================================================================= | 41% | |======================================================================================================================================================================================================== | 43% | |=============================================================================================================================================================================================================== | 44% | |===================================================================================================================================================================================================================== | 45% | |============================================================================================================================================================================================================================ | 47% | |=================================================================================================================================================================================================================================== | 48% | |========================================================================================================================================================================================================================================= | 50% | |================================================================================================================================================================================================================================================ | 51% | |======================================================================================================================================================================================================================================================= | 52% | |============================================================================================================================================================================================================================================================= | 54% | |==================================================================================================================================================================================================================================================================== | 55% | |========================================================================================================================================================================================================================================================================== | 57% | |================================================================================================================================================================================================================================================================================= | 58% | |======================================================================================================================================================================================================================================================================================== | 60% | |============================================================================================================================================================================================================================================================================================== | 61% | |===================================================================================================================================================================================================================================================================================================== | 62% | |============================================================================================================================================================================================================================================================================================================ | 64% | |================================================================================================================================================================================================================================================================================================================== | 65% | |========================================================================================================================================================================================================================================================================================================================= | 67% | |================================================================================================================================================================================================================================================================================================================================ | 68% | |====================================================================================================================================================================================================================================================================================================================================== | 69% | |============================================================================================================================================================================================================================================================================================================================================= | 71% | |==================================================================================================================================================================================================================================================================================================================================================== | 72% | |========================================================================================================================================================================================================================================================================================================================================================== | 74% | |================================================================================================================================================================================================================================================================================================================================================================= | 75% | |======================================================================================================================================================================================================================================================================================================================================================================== | 77% | |============================================================================================================================================================================================================================================================================================================================================================================== | 78% | |===================================================================================================================================================================================================================================================================================================================================================================================== | 79% | |============================================================================================================================================================================================================================================================================================================================================================================================ | 81% | |================================================================================================================================================================================================================================================================================================================================================================================================== | 82% | |========================================================================================================================================================================================================================================================================================================================================================================================================= | 84% | |================================================================================================================================================================================================================================================================================================================================================================================================================ | 85% | |====================================================================================================================================================================================================================================================================================================================================================================================================================== | 86% | |============================================================================================================================================================================================================================================================================================================================================================================================================================= | 88% | |=================================================================================================================================================================================================================================================================================================================================================================================================================================== | 89% | |========================================================================================================================================================================================================================================================================================================================================================================================================================================== | 91% | |================================================================================================================================================================================================================================================================================================================================================================================================================================================= | 92% | |======================================================================================================================================================================================================================================================================================================================================================================================================================================================= | 93% | |============================================================================================================================================================================================================================================================================================================================================================================================================================================================== | 95% | |===================================================================================================================================================================================================================================================================================================================================================================================================================================================================== | 96% | |=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================== | 98% | |================================================================================================================================================================================================================================================================================================================================================================================================================================================================================== | 99% | |======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================| 100%
:) Simple feature collection with 1001 features and 4 fields (with 7 geometries empty)
:) Geometry type: MULTIPOLYGON
:) Dimension: XY
:) Bounding box: xmin: -125 ymin: 42 xmax: -116 ymax: 46.3
:) Geodetic CRS: WGS 84
:) First 10 features:
:) GEOID NAME hhincomeE hhincomeM geometry
:) 1 41047001607 Census Tract 16.07, Marion County, Oregon 39650 18013 MULTIPOLYGON (((-123 45, -1...
:) 2 41005980000 Census Tract 9800, Clackamas County, Oregon NA NA MULTIPOLYGON (((-122 45.2, ...
:) 3 41051001301 Census Tract 13.01, Multnomah County, Oregon 85122 13294 MULTIPOLYGON (((-123 45.5, ...
:) 4 41067031516 Census Tract 315.16, Washington County, Oregon 169135 35939 MULTIPOLYGON (((-123 45.5, ...
:) 5 41059950500 Census Tract 9505, Umatilla County, Oregon 65343 8466 MULTIPOLYGON (((-119 45.7, ...
:) 6 41051005103 Census Tract 51.03, Multnomah County, Oregon 24614 9410 MULTIPOLYGON (((-123 45.5, ...
:) 7 41051006701 Census Tract 67.01, Multnomah County, Oregon 131071 24415 MULTIPOLYGON (((-123 45.5, ...
:) 8 41051009604 Census Tract 96.04, Multnomah County, Oregon 54308 5067 MULTIPOLYGON (((-122 45.5, ...
:) 9 41017001602 Census Tract 16.02, Deschutes County, Oregon 64397 27942 MULTIPOLYGON (((-121 44.1, ...
:) 10 41043030300 Census Tract 303, Linn County, Oregon 70431 6997 MULTIPOLYGON (((-123 44.4, ...
The 23 census tracts below completely cover the boundary of Springfield.
:) Simple feature collection with 24 features and 4 fields
:) Geometry type: MULTIPOLYGON
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44 xmax: -123 ymax: 44.3
:) Geodetic CRS: WGS 84
:) First 10 features:
:) GEOID NAME hhincomeE hhincomeM geometry
:) 274 41039003103 Census Tract 31.03, Lane County, Oregon 84231 16278 MULTIPOLYGON (((-123 44.1, ...
:) 276 41039002104 Census Tract 21.04, Lane County, Oregon 35171 8497 MULTIPOLYGON (((-123 44.1, ...
:) 414 41039003500 Census Tract 35, Lane County, Oregon 64224 13390 MULTIPOLYGON (((-123 44, -1...
:) 467 41039003700 Census Tract 37, Lane County, Oregon 24475 4179 MULTIPOLYGON (((-123 44.1, ...
:) 493 41039003104 Census Tract 31.04, Lane County, Oregon 43226 7973 MULTIPOLYGON (((-123 44.1, ...
:) 518 41039003600 Census Tract 36, Lane County, Oregon 65746 11302 MULTIPOLYGON (((-123 44, -1...
:) 540 41039003202 Census Tract 32.02, Lane County, Oregon 60921 14134 MULTIPOLYGON (((-123 44.1, ...
:) 555 41039003301 Census Tract 33.01, Lane County, Oregon 60471 8362 MULTIPOLYGON (((-123 44.1, ...
:) 561 41039003302 Census Tract 33.02, Lane County, Oregon 48074 9036 MULTIPOLYGON (((-123 44.1, ...
:) 580 41039003400 Census Tract 34, Lane County, Oregon 51799 4260 MULTIPOLYGON (((-123 44, -1...
The black line shows the boundary of Springfield, and the polygons colored in either yellow or brown-ish color are census tracts. Additionally, I provided a cloropleth of the 23 census tracts in terms of the estimated median household income. High income neighborhoods are located at the outskirt of the city, both on the east and west side of the city.
tmap_mode('view')
tm_shape(tract_spring) +
tm_polygons(col = "hhincomeE", alpha=0.5) +
tm_shape(spring) +
tm_borders(col="black", lwd=2) +
tm_layout(
legend.title.size = 4,
legend.text.size = 5,
legend.position = c("right","bottom"),
main.title = "City of Springfield and 23 Census Tracts", main.title.position = "left", main.title.size = 7
) +
tm_layout(frame = FALSE)
I removed the census tract with the largest area (GEOID: 41039000200) because it barely touches the boundary of the City of Springfield.
:) Simple feature collection with 23 features and 4 fields
:) Geometry type: MULTIPOLYGON
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44 xmax: -123 ymax: 44.1
:) Geodetic CRS: WGS 84
:) First 10 features:
:) GEOID NAME hhincomeE hhincomeM geometry
:) 1 41039003103 Census Tract 31.03, Lane County, Oregon 84231 16278 MULTIPOLYGON (((-123 44.1, ...
:) 2 41039002104 Census Tract 21.04, Lane County, Oregon 35171 8497 MULTIPOLYGON (((-123 44.1, ...
:) 3 41039003500 Census Tract 35, Lane County, Oregon 64224 13390 MULTIPOLYGON (((-123 44, -1...
:) 4 41039003700 Census Tract 37, Lane County, Oregon 24475 4179 MULTIPOLYGON (((-123 44.1, ...
:) 5 41039003104 Census Tract 31.04, Lane County, Oregon 43226 7973 MULTIPOLYGON (((-123 44.1, ...
:) 6 41039003600 Census Tract 36, Lane County, Oregon 65746 11302 MULTIPOLYGON (((-123 44, -1...
:) 7 41039003202 Census Tract 32.02, Lane County, Oregon 60921 14134 MULTIPOLYGON (((-123 44.1, ...
:) 8 41039003301 Census Tract 33.01, Lane County, Oregon 60471 8362 MULTIPOLYGON (((-123 44.1, ...
:) 9 41039003302 Census Tract 33.02, Lane County, Oregon 48074 9036 MULTIPOLYGON (((-123 44.1, ...
:) 10 41039003400 Census Tract 34, Lane County, Oregon 51799 4260 MULTIPOLYGON (((-123 44, -1...
2 Find the radius covering each census tract to use it as the spatial unit for Yelp API request
2.1 The first census tract as an illustrative example.
# finding the bounding box of the first census tract
bb <- tract_spring[1,] %>%
st_transform(4326) %>%
st_bbox()
print(bb)
:) xmin ymin xmax ymax
:) -123.1 44.1 -123.0 44.1
:) 'bbox' Named num [1:4] -123.1 44.1 -123 44.1
:) - attr(*, "names")= chr [1:4] "xmin" "ymin" "xmax" "ymax"
:) - attr(*, "crs")=List of 2
:) ..$ input: chr "EPSG:4326"
:) ..$ wkt : chr "GEOGCRS[\"WGS 84\",\n ENSEMBLE[\"World Geodetic System 1984 ensemble\",\n MEMBER[\"World Geodetic Sys"| __truncated__
:) ..- attr(*, "class")= chr "crs"
:) NULL
# Finding the centroid of the bounding box
bb_corner <- st_point(c(bb[1], bb[2])) %>% st_sfc(crs = 4326) %>% st_sf
bb_center_x <- (bb[1] + bb[3]) / 2
bb_center_y <- (bb[2] + bb[4]) / 2
bb_center <- st_point(c(bb_center_x, bb_center_y)) %>% st_sfc(crs = 4326) %>% st_sf
# Finding a radius that could fully cover the census tract by calcuating the distance between one of the corners and the center
r <- st_distance(bb_corner, bb_center)
bb_center$radius <- r*1.1
tm_shape(tract_spring[1,]) + tm_borders() +
tm_shape(bb_corner) + tm_dots(size=1) +
tm_shape(bb_center) + tm_dots(size=1) +
tm_shape(bb_center %>% st_buffer(., dist = .$radius)) + tm_polygons(col ="yellow", alpha=0.3)
2.2 Apply the above method to all census tracts
# Defining a function that can draw the radius for each census tract
get_radius <- function(polygon, epsg_id){
bb <- polygon %>% st_bbox()
bb_corner <- st_point(c(bb[1], bb[2])) %>% st_sfc(crs = epsg_id) %>% st_sf()
bb_center_x <- (bb[1] + bb[3]) / 2
bb_center_y <- (bb[2] + bb[4]) / 2
bb_center <- st_point(c(bb_center_x, bb_center_y)) %>% st_sfc(crs = epsg_id) %>% st_sf()
r <- st_distance(bb_corner, bb_center)
bb_center$radius <- r*1.1
return(bb_center)
}
# Using `purrr` package to apply the defined function to each tract
tract_spring_radius <- tract_spring %>%
st_geometry() %>%
st_transform(crs = 4326) %>%
purrr::map(., function(x) get_radius(x, epsg_id = 4326))
tract_spring_radius %>% head()
:) [[1]]
:) Simple feature collection with 1 feature and 1 field
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44.1 xmax: -123 ymax: 44.1
:) Geodetic CRS: WGS 84
:) geometry radius
:) 1 POINT (-123 44.1) 1445 [m]
:)
:) [[2]]
:) Simple feature collection with 1 feature and 1 field
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44.1 xmax: -123 ymax: 44.1
:) Geodetic CRS: WGS 84
:) geometry radius
:) 1 POINT (-123 44.1) 1194 [m]
:)
:) [[3]]
:) Simple feature collection with 1 feature and 1 field
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44 xmax: -123 ymax: 44
:) Geodetic CRS: WGS 84
:) geometry radius
:) 1 POINT (-123 44) 6104 [m]
:)
:) [[4]]
:) Simple feature collection with 1 feature and 1 field
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44 xmax: -123 ymax: 44
:) Geodetic CRS: WGS 84
:) geometry radius
:) 1 POINT (-123 44) 2000 [m]
:)
:) [[5]]
:) Simple feature collection with 1 feature and 1 field
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44.1 xmax: -123 ymax: 44.1
:) Geodetic CRS: WGS 84
:) geometry radius
:) 1 POINT (-123 44.1) 1921 [m]
:)
:) [[6]]
:) Simple feature collection with 1 feature and 1 field
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44 xmax: -123 ymax: 44
:) Geodetic CRS: WGS 84
:) geometry radius
:) 1 POINT (-123 44) 4130 [m]
# Transforming the list to a dataframe
tract_spring_radius <- tract_spring_radius %>% bind_rows()
tract_spring_radius
:) Simple feature collection with 23 features and 1 field
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44 xmax: -123 ymax: 44.1
:) Geodetic CRS: WGS 84
:) First 10 features:
:) radius geometry
:) 1 1445 [m] POINT (-123 44.1)
:) 2 1194 [m] POINT (-123 44.1)
:) 3 6104 [m] POINT (-123 44)
:) 4 2000 [m] POINT (-123 44)
:) 5 1921 [m] POINT (-123 44.1)
:) 6 4130 [m] POINT (-123 44)
:) 7 1419 [m] POINT (-123 44.1)
:) 8 1376 [m] POINT (-123 44.1)
:) 9 1192 [m] POINT (-123 44)
:) 10 1573 [m] POINT (-123 44.1)
Yellow circles show the radius of each census tract. They will be used as a spatial unity to request POI data through the Yelp API.
3 Access Yelp API using
the yelpr
package
3.1 The first census tract as an illustrative example.
# Explicitly defining the longitude and latitude coordinate to conform to the Yelp API format
tract_spring_radius <- tract_spring_radius %>%
mutate(x = st_coordinates(.)[,1],
y = st_coordinates(.)[,2])
tract_spring_radius
:) Simple feature collection with 23 features and 3 fields
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44 xmax: -123 ymax: 44.1
:) Geodetic CRS: WGS 84
:) First 10 features:
:) radius geometry x y
:) 1 1445 [m] POINT (-123 44.1) -123 44.1
:) 2 1194 [m] POINT (-123 44.1) -123 44.1
:) 3 6104 [m] POINT (-123 44) -123 44.0
:) 4 2000 [m] POINT (-123 44) -123 44.0
:) 5 1921 [m] POINT (-123 44.1) -123 44.1
:) 6 4130 [m] POINT (-123 44) -123 44.0
:) 7 1419 [m] POINT (-123 44.1) -123 44.1
:) 8 1376 [m] POINT (-123 44.1) -123 44.1
:) 9 1192 [m] POINT (-123 44) -123 44.0
:) 10 1573 [m] POINT (-123 44.1) -123 44.1
:) Simple feature collection with 1 feature and 3 fields
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44.1 xmax: -123 ymax: 44.1
:) Geodetic CRS: WGS 84
:) radius geometry x y
:) 1 1445 [m] POINT (-123 44.1) -123 44.1
I requested Pizza stores in the first census tract using the
yelpr
package. There are 28 Pizza stores.
tract_each <- 1
resp <- yelpr::business_search(api_key = Sys.getenv("yelp_api2"),
# location = ,
latitude = as.numeric(tract_spring_radius[tract_each, ]$y),
longitude = as.numeric(tract_spring_radius[tract_each, ]$x),
offset = 0,
radius = round(tract_spring_radius[tract_each, ]$radius),
limit = 50,
categories = "pizza")
resp
:) $businesses
:) id alias name image_url is_closed url review_count categories rating coordinates.latitude coordinates.longitude
:) 1 RW7UfCVzCtjdR8VjARO8AQ pegasus-pizza-eugene-3 Pegasus Pizza https://s3-media1.fl.yelpcdn.com/bphoto/k-7mgGV78S1vfUlimAiIdg/o.jpg FALSE https://www.yelp.com/biz/pegasus-pizza-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=2OO9o_S_kV__48TL7V_Q1g 82 pizza, cocktailbars, Pizza, Cocktail Bars 3.3 44.1 -123
:) 2 -OSaiVv0i9donG_5-Ov-kw mod-pizza-eugene MOD Pizza https://s3-media2.fl.yelpcdn.com/bphoto/jwQAWViCUiO7lJuxRkPdRw/o.jpg FALSE https://www.yelp.com/biz/mod-pizza-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=2OO9o_S_kV__48TL7V_Q1g 191 hotdogs, pizza, Fast Food, Pizza 3.5 44.1 -123
:) transactions price location.address1 location.address2 location.address3 location.city location.zip_code location.country location.state location.display_address phone display_phone distance business_hours attributes.business_temp_closed
:) 1 pickup, delivery $ 4 Oakway Ctr Eugene 97401 US OR 4 Oakway Ctr, Eugene, OR 97401 +15413440844 (541) 344-0844 1043 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 1100, 1100, 1100, 1100, 1100, 1100, 1100, 2000, 2000, 2000, 2000, 2100, 2100, 2000, 0, 1, 2, 3, 4, 5, 6, REGULAR, TRUE NA
:) 2 pickup, delivery $ 203 Coburg Rd <NA> <NA> Eugene 97401 US OR 203 Coburg Rd, Eugene, OR 97401 +14582058910 (458) 205-8910 1027 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 2200, 2200, 2200, 2300, 2300, 2300, 2200, 0, 1, 2, 3, 4, 5, 6, REGULAR, TRUE NA
:) attributes.menu_url attributes.open24_hours attributes.waitlist_reservation
:) 1 http://pegasuspizza.net/#menu NA NA
:) 2 http://modpizza.com/menu/?utm_campaign=yelplistingbusiness&utm_medium=referral&utm_source=yelp&utm_content=menu NA NA
:) [ reached getOption("max.print") -- omitted 2 rows ]
:) [ reached 'max' / getOption("max.print") -- omitted 2 rows ]
:)
:) $total
:) [1] 6
:)
:) $region
:) $region$center
:) $region$center$longitude
:) [1] -123
:)
:) $region$center$latitude
:) [1] 44.1
library(glue)
nr <- nrow(resp$businesses)
nc <- ncol(resp$businesses)
glue("The result has {nr} rows and {nc} columns.")
:) The result has 6 rows and 18 columns.
3.2 Build a API request function
# as an example
tract_each <- tract_spring_radius[1,]
category <- "pizza"
i = 1
yelpr::business_search(api_key = Sys.getenv("yelp_api2"),
# location = ,
latitude = as.numeric(tract_each$y),
longitude = as.numeric(tract_each$x),
offset = (i-1)*50,
radius = round(tract_each$radius),
limit = 50,
categories = category)
:) $businesses
:) id alias name image_url is_closed url review_count categories rating coordinates.latitude coordinates.longitude
:) 1 RW7UfCVzCtjdR8VjARO8AQ pegasus-pizza-eugene-3 Pegasus Pizza https://s3-media1.fl.yelpcdn.com/bphoto/k-7mgGV78S1vfUlimAiIdg/o.jpg FALSE https://www.yelp.com/biz/pegasus-pizza-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=2OO9o_S_kV__48TL7V_Q1g 82 pizza, cocktailbars, Pizza, Cocktail Bars 3.3 44.1 -123
:) 2 -OSaiVv0i9donG_5-Ov-kw mod-pizza-eugene MOD Pizza https://s3-media2.fl.yelpcdn.com/bphoto/jwQAWViCUiO7lJuxRkPdRw/o.jpg FALSE https://www.yelp.com/biz/mod-pizza-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=2OO9o_S_kV__48TL7V_Q1g 191 hotdogs, pizza, Fast Food, Pizza 3.5 44.1 -123
:) transactions price location.address1 location.address2 location.address3 location.city location.zip_code location.country location.state location.display_address phone display_phone distance business_hours attributes.business_temp_closed
:) 1 delivery, pickup $ 4 Oakway Ctr Eugene 97401 US OR 4 Oakway Ctr, Eugene, OR 97401 +15413440844 (541) 344-0844 1043 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 1100, 1100, 1100, 1100, 1100, 1100, 1100, 2000, 2000, 2000, 2000, 2100, 2100, 2000, 0, 1, 2, 3, 4, 5, 6, REGULAR, TRUE NA
:) 2 delivery, pickup $ 203 Coburg Rd <NA> <NA> Eugene 97401 US OR 203 Coburg Rd, Eugene, OR 97401 +14582058910 (458) 205-8910 1027 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 2200, 2200, 2200, 2300, 2300, 2300, 2200, 0, 1, 2, 3, 4, 5, 6, REGULAR, TRUE NA
:) attributes.menu_url attributes.open24_hours attributes.waitlist_reservation
:) 1 http://pegasuspizza.net/#menu NA NA
:) 2 http://modpizza.com/menu/?utm_campaign=yelplistingbusiness&utm_medium=referral&utm_source=yelp&utm_content=menu NA NA
:) [ reached getOption("max.print") -- omitted 2 rows ]
:) [ reached 'max' / getOption("max.print") -- omitted 2 rows ]
:)
:) $total
:) [1] 6
:)
:) $region
:) $region$center
:) $region$center$longitude
:) [1] -123
:)
:) $region$center$latitude
:) [1] 44.1
# Defining a function to request through the API
get_yelp <- function(tract_each, category){
# Breaks are needed to avoid API request violations
Sys.sleep(1)
# bring one census tract
tract_each <- tract_spring_radius[tract_each, ]
# the first trial for a tract
i <- 1
resp <- yelpr::business_search(api_key = Sys.getenv("yelp_api2"),
# location = ,
latitude = as.numeric(tract_each$y),
longitude = as.numeric(tract_each$x),
offset = (i-1)*50,
radius = round(tract_each$radius),
limit = 50,
categories = category)
# Estimating how many trials of API requests are needed for this tract
required_n <- ceiling(resp$total/50)
# Applying different strategies of API requests based on the estimated trials
if (resp$total >= 1000){
print(glue::glue("This census tract has {required_n} (>=1000) {category}s, so the data needs to be collected in a smaller scale."))}
else {
# in case there is no POI at all belonging to the category in the census tract
if (required_n == 0){
tract_each_result <- vector("list", 1)
tract_each_result[[i]] <- resp$businesses}
# in case only one request per census tract is needed
else if (required_n == 1){
tract_each_result <- vector("list", 1)
tract_each_result[[i]] <- resp$businesses}
# in case we need than 20 or less requests to retrieve all POIs beloning to the category
else {
tract_each_result <- vector("list", required_n)
i <- i+1
while(i <= required_n){
Sys.sleep(1)
resp <- yelpr::business_search(api_key = Sys.getenv("yelp_api2"),
# location = ,
latitude = as.numeric(tract_each$y),
longitude = as.numeric(tract_each$x),
offset = 0,
radius = round(tract_each$radius),
limit = 50,
categories = category)
tract_each_result[[i]] <- resp$businesses
i <- i+1}}}
tract_each_result <- tract_each_result %>% bind_rows()
return(tract_each_result)
}
:) # A tibble: 6 × 18
:) id alias name image_url is_closed url review_count categories rating coordinates$latitude transactions price location$address1 phone display_phone distance business_hours attributes$business_…¹
:) <chr> <chr> <chr> <chr> <lgl> <chr> <int> <list> <dbl> <dbl> <list> <chr> <chr> <chr> <chr> <dbl> <list> <lgl>
:) 1 RW7UfCVzCtjdR8VjARO8AQ pegasus-pizza-eugene-3 Pegasus Pizza https://s3-media1.fl.yelpcdn.com/bphoto/k-7mgGV78S1vfUlimAiIdg/o.jpg FALSE https://www.yelp.com/biz/pegasus-pizza-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&ut… 82 <df> 3.3 44.1 <chr [2]> $ 4 Oakway Ctr +154… (541) 344-08… 1043. <df [1 × 3]> NA
:) 2 -OSaiVv0i9donG_5-Ov-kw mod-pizza-eugene MOD Pizza https://s3-media2.fl.yelpcdn.com/bphoto/jwQAWViCUiO7lJuxRkPdRw/o.jpg FALSE https://www.yelp.com/biz/mod-pizza-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_sour… 191 <df> 3.5 44.1 <chr [2]> $ 203 Coburg Rd +145… (458) 205-89… 1027. <df [1 × 3]> NA
:) 3 yHY_0PIIGfOGms5h-JpD5Q the-o-bar-and-grill-eugene-3 The O Bar & Grill https://s3-media2.fl.yelpcdn.com/bphoto/nmuKD7EbGWHuPKdbcJQSpA/o.jpg FALSE https://www.yelp.com/biz/the-o-bar-and-grill-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_sea… 61 <df> 2.9 44.1 <chr [2]> $ 115 Commons Dr +154… (541) 349-07… 920. <df [1 × 3]> NA
:) 4 dghvrys0A_V41ibPXj7yUA papas-pizza-parlor-eugene-7 Papa's Pizza Parlor - Coburg Rd Eugene https://s3-media1.fl.yelpcdn.com/bphoto/6n1wEgF7F9b6oLz6DOThRQ/o.jpg FALSE https://www.yelp.com/biz/papas-pizza-parlor-eugene-7?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_sear… 85 <df> 2.5 44.1 <chr [0]> $$ 1577 Coburg Rd +154… (541) 686-07… 1467. <df [1 × 3]> NA
:) 5 YKh7HaUzjizeHrIebkFAAQ papa-murphys-eugene-2 Papa Murphy's https://s3-media1.fl.yelpcdn.com/bphoto/jL-QyMy_7RIeK0E05H6xnQ/o.jpg FALSE https://www.yelp.com/biz/papa-murphys-eugene-2?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm… 24 <df> 3.3 44.1 <chr [1]> $ 1508 Coburg Road +154… (541) 686-66… 1447. <df [0 × 0]> NA
:) 6 i1uc9dtkqdbgjjakeTjOxw cork-and-kale-restaurant-eugene Cork & Kale Restaurant https://s3-media2.fl.yelpcdn.com/bphoto/UYHwvthpTSlSe3E3vsQANw/o.jpg FALSE https://www.yelp.com/biz/cork-and-kale-restaurant-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_… 8 <df> 3.1 44.1 <chr [0]> <NA> 2133 Centennial … +154… (541) 342-38… 1288. <df [1 × 3]> NA
:) # ℹ abbreviated name: ¹​attributes$business_temp_closed
:) # ℹ 11 more variables: coordinates$longitude <dbl>, location$address2 <chr>, $address3 <chr>, $city <chr>, $zip_code <chr>, $country <chr>, $state <chr>, $display_address <list>, attributes$menu_url <chr>, $open24_hours <lgl>, $waitlist_reservation <lgl>
3.3 Scarping for Pizza restaurants and Breweries
I selected Pizza restaurants and Breweries as two POI categories. The former represents daily menus, while the latter represents places we visit occasionally to hang out with friends. Given that people drink beers at breweries, breweries are hardly places where we can go daily, especially on the weekdays. It would be interesting to compare the spatial distribution of the two categories.
category <- "pizza"
yelp_result_all_pizza <- vector("list", nrow(tract_spring_radius))
for (tract_each in 1:nrow(tract_spring_radius)){
yelp_result_all_pizza[[tract_each]] <- suppressMessages(get_yelp(tract_each, category))
print(glue::glue("Retrieving {tract_each}th census tract"))
}
:) Retrieving 1th census tract
:) Retrieving 2th census tract
:) Retrieving 3th census tract
:) Retrieving 4th census tract
:) Retrieving 5th census tract
:) Retrieving 6th census tract
:) Retrieving 7th census tract
:) Retrieving 8th census tract
:) Retrieving 9th census tract
:) Retrieving 10th census tract
:) Retrieving 11th census tract
:) Retrieving 12th census tract
:) Retrieving 13th census tract
:) Retrieving 14th census tract
:) Retrieving 15th census tract
:) Retrieving 16th census tract
:) Retrieving 17th census tract
:) Retrieving 18th census tract
:) Retrieving 19th census tract
:) Retrieving 20th census tract
:) Retrieving 21th census tract
:) Retrieving 22th census tract
:) Retrieving 23th census tract
:) id alias name image_url is_closed url review_count categories rating coordinates.latitude coordinates.longitude
:) 1 RW7UfCVzCtjdR8VjARO8AQ pegasus-pizza-eugene-3 Pegasus Pizza https://s3-media1.fl.yelpcdn.com/bphoto/k-7mgGV78S1vfUlimAiIdg/o.jpg FALSE https://www.yelp.com/biz/pegasus-pizza-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=2OO9o_S_kV__48TL7V_Q1g 82 pizza, cocktailbars, Pizza, Cocktail Bars 3.3 44.1 -123
:) 2 -OSaiVv0i9donG_5-Ov-kw mod-pizza-eugene MOD Pizza https://s3-media2.fl.yelpcdn.com/bphoto/jwQAWViCUiO7lJuxRkPdRw/o.jpg FALSE https://www.yelp.com/biz/mod-pizza-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=2OO9o_S_kV__48TL7V_Q1g 191 hotdogs, pizza, Fast Food, Pizza 3.5 44.1 -123
:) transactions price location.address1 location.address2 location.address3 location.city location.zip_code location.country location.state location.display_address phone display_phone distance business_hours attributes.business_temp_closed
:) 1 delivery, pickup $ 4 Oakway Ctr Eugene 97401 US OR 4 Oakway Ctr, Eugene, OR 97401 +15413440844 (541) 344-0844 1043 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 1100, 1100, 1100, 1100, 1100, 1100, 1100, 2000, 2000, 2000, 2000, 2100, 2100, 2000, 0, 1, 2, 3, 4, 5, 6, REGULAR, TRUE NA
:) 2 delivery, pickup $ 203 Coburg Rd <NA> <NA> Eugene 97401 US OR 203 Coburg Rd, Eugene, OR 97401 +14582058910 (458) 205-8910 1027 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 2200, 2200, 2200, 2300, 2300, 2300, 2200, 0, 1, 2, 3, 4, 5, 6, REGULAR, TRUE NA
:) attributes.menu_url attributes.open24_hours attributes.waitlist_reservation
:) 1 http://pegasuspizza.net/#menu NA NA
:) 2 http://modpizza.com/menu/?utm_campaign=yelplistingbusiness&utm_medium=referral&utm_source=yelp&utm_content=menu NA NA
:) [ reached getOption("max.print") -- omitted 2 rows ]
:) [ reached 'max' / getOption("max.print") -- omitted 185 rows ]
category <- "breweries"
yelp_result_all_breweries <- vector("list", nrow(tract_spring_radius))
for (tract_each in 1:nrow(tract_spring_radius)){
yelp_result_all_breweries[[tract_each]] <- suppressMessages(get_yelp(tract_each, category))
print(glue::glue("Retrieving {tract_each}th census tract"))
}
:) Retrieving 1th census tract
:) Retrieving 2th census tract
:) Retrieving 3th census tract
:) Retrieving 4th census tract
:) Retrieving 5th census tract
:) Retrieving 6th census tract
:) Retrieving 7th census tract
:) Retrieving 8th census tract
:) Retrieving 9th census tract
:) Retrieving 10th census tract
:) Retrieving 11th census tract
:) Retrieving 12th census tract
:) Retrieving 13th census tract
:) Retrieving 14th census tract
:) Retrieving 15th census tract
:) Retrieving 16th census tract
:) Retrieving 17th census tract
:) Retrieving 18th census tract
:) Retrieving 19th census tract
:) Retrieving 20th census tract
:) Retrieving 21th census tract
:) Retrieving 22th census tract
:) Retrieving 23th census tract
:) # A tibble: 32 × 18
:) id alias name image_url is_closed url review_count categories rating coordinates$latitude transactions price location$address1 phone display_phone distance business_hours attributes$business_…¹
:) <chr> <chr> <chr> <chr> <lgl> <chr> <int> <list> <dbl> <dbl> <list> <chr> <chr> <chr> <chr> <dbl> <list> <lgl>
:) 1 pYjdI9a-ssScMtkY5mXmjA plank-town-brewing-co-springfield Plank Town Brewing Co https://s3-media2.fl.yelpcdn.com/bphoto/Zh92eokS-MREvdxGiYsyLg/o.jpg FALSE https://www.yelp.com/biz/plank-town-brewing-co-springfield?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medi… 493 <df> 3.6 44.0 <chr [1]> $$ 346 Main St +154… (541) 746-18… 5145. <df [1 × 3]> NA
:) 2 lHku4SlBv4yRHQpKQVgyTQ falling-sky-brewing-eugene-2 Falling Sky Brewing https://s3-media2.fl.yelpcdn.com/bphoto/Cr58kTxyYlPGynGZuKQvtw/o.jpg FALSE https://www.yelp.com/biz/falling-sky-brewing-eugene-2?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=ap… 703 <df> 4 44.0 <chr [2]> $$ 1334 Oak Aly +154… (541) 505-70… 1906. <df [1 × 3]> NA
:) 3 646gAhT5sJsaVOvVdg3p9w mcmenamins-high-street-brewery-and-cafe-eugene-2 McMenamins High Street Brewery & Cafe https://s3-media1.fl.yelpcdn.com/bphoto/Po26WIaVCdUfOrkglfF4QA/o.jpg FALSE https://www.yelp.com/biz/mcmenamins-high-street-brewery-and-cafe-eugene-2?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_… 168 <df> 3.7 44.0 <chr [1]> $$ 1243 High St. +154… (541) 345-49… 1566. <df [1 × 3]> NA
:) 4 YnjnZUfdtpGUjnIBUJ034w gratitude-brewing-eugene Gratitude Brewing https://s3-media4.fl.yelpcdn.com/bphoto/ePtSoPqp0OtUcILhXiH2rQ/o.jpg FALSE https://www.yelp.com/biz/gratitude-brewing-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3… 40 <df> 4.5 44.1 <chr [1]> $$ 540 E 8th Ave +154… (541) 654-50… 1316. <df [1 × 3]> NA
:) 5 A6Kg53f0zusRQXAlHWHXQA coldfire-brewing-eugene ColdFire Brewing https://s3-media3.fl.yelpcdn.com/bphoto/0v0QYVLFxXvWcV-FoRZhXg/o.jpg FALSE https://www.yelp.com/biz/coldfire-brewing-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_… 121 <df> 4.7 44.1 <chr [0]> $$ 263 Mill St +154… (541) 636-38… 1699. <df [1 × 3]> NA
:) 6 _RcmRae05yeTwZZPh2uFyA claim-52-brewing-eugene Claim 52 Brewing https://s3-media2.fl.yelpcdn.com/bphoto/HVZSke4Mk-xRUbzPPj1FxA/o.jpg FALSE https://www.yelp.com/biz/claim-52-brewing-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_… 28 <df> 4.4 44.0 <chr [1]> $ 1203 Willamette … +154… (541) 844-01… 1929. <df [1 × 3]> NA
:) 7 wSMQ4shfDKOoU4k8RIeu6Q silver-falls-brewery-barrel-house-eugene Silver Falls Brewery Barrel House https://s3-media2.fl.yelpcdn.com/bphoto/9fkRIDslfkyr62iB1LIBbQ/o.jpg FALSE https://www.yelp.com/biz/silver-falls-brewery-barrel-house-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&u… 13 <df> 4.5 44.1 <chr [0]> <NA> 207 E 5th Ave +154… (541) 393-63… 1778. <df [1 × 3]> NA
:) 8 lQyzTnVjgCS18l_GocH2_w alesong-on-5th-eugene Alesong on 5th https://s3-media2.fl.yelpcdn.com/bphoto/umqo1ocuKRpSzk_OG5hz9Q/o.jpg FALSE https://www.yelp.com/biz/alesong-on-5th-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium=api_v3_bu… 13 <df> 4.1 44.1 <chr [0]> $$ 248 E 5th Ave +154… (541) 505-90… 1768. <df [1 × 3]> NA
:) 9 fZHM-3PMaPbuoAYrjGvBkA manifest-bar-and-brewery-eugene Manifest Bar & Brewery https://s3-media2.fl.yelpcdn.com/bphoto/Mm0OdGV1PT7LXi3VWIk7Rg/o.jpg FALSE https://www.yelp.com/biz/manifest-bar-and-brewery-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_api_v3&utm_medium… 1 <df> 5 44.1 <chr [0]> <NA> 740 Willamette St +154… (541) 632-39… 1985. <df [1 × 3]> NA
:) 10 646gAhT5sJsaVOvVdg3p9w mcmenamins-high-street-brewery-and-cafe-eugene-2 McMenamins High Street Brewery & Cafe https://s3-media1.fl.yelpcdn.com/bphoto/Po26WIaVCdUfOrkglfF4QA/o.jpg FALSE https://www.yelp.com/biz/mcmenamins-high-street-brewery-and-cafe-eugene-2?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_… 168 <df> 3.7 44.0 <chr [1]> $$ 1243 High St. +154… (541) 345-49… 1921. <df [1 × 3]> NA
:) # ℹ 22 more rows
:) # ℹ abbreviated name: ¹​attributes$business_temp_closed
:) # ℹ 11 more variables: coordinates$longitude <dbl>, location$address2 <chr>, $address3 <chr>, $city <chr>, $zip_code <chr>, $country <chr>, $state <chr>, $display_address <list>, attributes$menu_url <chr>, $open24_hours <lgl>, $waitlist_reservation <lgl>
4 Analysis
Using the retrieved dataset, I did a brief spatial analysis and visualization.
yelp_result_all_pizza <- yelp_result_all_pizza %>%
as_tibble() %>%
mutate(x = .$coordinates$longitude,
y = .$coordinates$latitude,
category_manual_input = "pizza")
yelp_result_all_pizza
:) # A tibble: 189 × 21
:) id alias name image_url is_closed url review_count categories rating coordinates$latitude transactions price location$address1 phone display_phone distance business_hours attributes$business_…¹ x y category_manual_input
:) <chr> <chr> <chr> <chr> <lgl> <chr> <int> <list> <dbl> <dbl> <list> <chr> <chr> <chr> <chr> <dbl> <list> <int> <dbl> <dbl> <chr>
:) 1 RW7UfCVzCtjdR8VjARO8AQ pegasus-pizza-eugene-3 Pegasus Pizza https://s3-media1.fl.yelpcdn.com/bphoto/k-7mgGV78S1vfUlimAiIdg/o.jpg FALSE https://www.yelp.com/biz/pegasus-pizza-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign… 82 <df> 3.3 44.1 <chr [2]> $ 4 Oakway Ctr +154… (541) 344-08… 1043. <df [1 × 3]> NA -123. 44.1 pizza
:) 2 -OSaiVv0i9donG_5-Ov-kw mod-pizza-eugene MOD Pizza https://s3-media2.fl.yelpcdn.com/bphoto/jwQAWViCUiO7lJuxRkPdRw/o.jpg FALSE https://www.yelp.com/biz/mod-pizza-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_… 191 <df> 3.5 44.1 <chr [2]> $ 203 Coburg Rd +145… (458) 205-89… 1027. <df [1 × 3]> NA -123. 44.1 pizza
:) 3 yHY_0PIIGfOGms5h-JpD5Q the-o-bar-and-grill-eugene-3 The O Bar & Grill https://s3-media2.fl.yelpcdn.com/bphoto/nmuKD7EbGWHuPKdbcJQSpA/o.jpg FALSE https://www.yelp.com/biz/the-o-bar-and-grill-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_ca… 61 <df> 2.9 44.1 <chr [2]> $ 115 Commons Dr +154… (541) 349-07… 920. <df [1 × 3]> NA -123. 44.1 pizza
:) 4 dghvrys0A_V41ibPXj7yUA papas-pizza-parlor-eugene-7 Papa's Pizza Parlor - Coburg Rd Eugene https://s3-media1.fl.yelpcdn.com/bphoto/6n1wEgF7F9b6oLz6DOThRQ/o.jpg FALSE https://www.yelp.com/biz/papas-pizza-parlor-eugene-7?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_cam… 85 <df> 2.5 44.1 <chr [0]> $$ 1577 Coburg Rd +154… (541) 686-07… 1467. <df [1 × 3]> NA -123. 44.1 pizza
:) 5 YKh7HaUzjizeHrIebkFAAQ papa-murphys-eugene-2 Papa Murphy's https://s3-media1.fl.yelpcdn.com/bphoto/jL-QyMy_7RIeK0E05H6xnQ/o.jpg FALSE https://www.yelp.com/biz/papa-murphys-eugene-2?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=… 24 <df> 3.3 44.1 <chr [1]> $ 1508 Coburg Road +154… (541) 686-66… 1447. <df [0 × 0]> NA -123. 44.1 pizza
:) 6 i1uc9dtkqdbgjjakeTjOxw cork-and-kale-restaurant-eugene Cork & Kale Restaurant https://s3-media2.fl.yelpcdn.com/bphoto/UYHwvthpTSlSe3E3vsQANw/o.jpg FALSE https://www.yelp.com/biz/cork-and-kale-restaurant-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm… 8 <df> 3.1 44.1 <chr [0]> <NA> 2133 Centennial … +154… (541) 342-38… 1288. <df [1 × 3]> NA -123. 44.1 pizza
:) 7 ArX9hk9qcL_OzVJsd4wP3g pieology-pizzeria-springfield-springfield Pieology Pizzeria, Springfield https://s3-media2.fl.yelpcdn.com/bphoto/tNoYjmdjwvsnj-dJ0s2ttw/o.jpg FALSE https://www.yelp.com/biz/pieology-pizzeria-springfield-springfield?adjust_creative=2OO9o_S_kV__48TL… 118 <df> 3.1 44.1 <chr [2]> $ 2860 Gateway Str… +154… (541) 357-43… 924. <df [1 × 3]> NA -123. 44.1 pizza
:) 8 ufwvXcRZdR_0e69QGsUm8Q little-caesars-pizza-springfield-5 Little Caesars Pizza https://s3-media2.fl.yelpcdn.com/bphoto/zuOoNYrMok4sIeeocmphTw/o.jpg FALSE https://www.yelp.com/biz/little-caesars-pizza-springfield-5?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&… 20 <df> 1.7 44.1 <chr [1]> $ 183 Q St +154… (541) 741-36… 1220. <df [1 × 3]> NA -123. 44.1 pizza
:) 9 _ORTNFlJjjm6Wy4TpS-7BA coburg-pizza-company-centennial-springfield-5 Coburg Pizza Company Centennial https://s3-media4.fl.yelpcdn.com/bphoto/BkjR8iTj-i_xP-C2pvffkQ/o.jpg FALSE https://www.yelp.com/biz/coburg-pizza-company-centennial-springfield-5?adjust_creative=2OO9o_S_kV__… 224 <df> 4.2 44.1 <chr [0]> $$ 1710 Centennial … +154… (541) 484-66… 4645. <df [1 × 3]> NA -123. 44.1 pizza
:) 10 SVulg_fxyYsyVBFzYvSeGQ bartolottis-pizza-bistro-springfield-2 Bartolotti's Pizza Bistro https://s3-media2.fl.yelpcdn.com/bphoto/NrHn5F5WqZYRGbbOMsjdUg/o.jpg FALSE https://www.yelp.com/biz/bartolottis-pizza-bistro-springfield-2?adjust_creative=2OO9o_S_kV__48TL7V_… 127 <df> 4.2 44.0 <chr [2]> $$ 330 Main St +154… (541) 505-88… 5171. <df [1 × 3]> NA -123. 44.0 pizza
:) # ℹ 179 more rows
:) # ℹ abbreviated name: ¹​attributes$business_temp_closed
:) # ℹ 11 more variables: coordinates$longitude <dbl>, location$address2 <chr>, $address3 <chr>, $city <chr>, $zip_code <chr>, $country <chr>, $state <chr>, $display_address <list>, attributes$menu_url <chr>, $open24_hours <lgl>, $waitlist_reservation <lgl>
yelp_result_all_breweries <- yelp_result_all_breweries %>%
as_tibble() %>%
mutate(x = .$coordinates$longitude,
y = .$coordinates$latitude,
category_manual_input = "breweries")
yelp_result_all_breweries
:) # A tibble: 32 × 21
:) id alias name image_url is_closed url review_count categories rating coordinates$latitude transactions price location$address1 phone display_phone distance business_hours attributes$business_…¹ x y category_manual_input
:) <chr> <chr> <chr> <chr> <lgl> <chr> <int> <list> <dbl> <dbl> <list> <chr> <chr> <chr> <chr> <dbl> <list> <lgl> <dbl> <dbl> <chr>
:) 1 pYjdI9a-ssScMtkY5mXmjA plank-town-brewing-co-springfield Plank Town Brewing Co https://s3-media2.fl.yelpcdn.com/bphoto/Zh92eokS-MREvdxGiYsyLg/o.jpg FALSE https://www.yelp.com/biz/plank-town-brewing-co-springfield?adjust_creative=2OO9o_S_kV__48TL7V_Q1g… 493 <df> 3.6 44.0 <chr [1]> $$ 346 Main St +154… (541) 746-18… 5145. <df [1 × 3]> NA -123. 44.0 breweries
:) 2 lHku4SlBv4yRHQpKQVgyTQ falling-sky-brewing-eugene-2 Falling Sky Brewing https://s3-media2.fl.yelpcdn.com/bphoto/Cr58kTxyYlPGynGZuKQvtw/o.jpg FALSE https://www.yelp.com/biz/falling-sky-brewing-eugene-2?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_… 703 <df> 4 44.0 <chr [2]> $$ 1334 Oak Aly +154… (541) 505-70… 1906. <df [1 × 3]> NA -123. 44.0 breweries
:) 3 646gAhT5sJsaVOvVdg3p9w mcmenamins-high-street-brewery-and-cafe-eugene-2 McMenamins High Street Brewery & Cafe https://s3-media1.fl.yelpcdn.com/bphoto/Po26WIaVCdUfOrkglfF4QA/o.jpg FALSE https://www.yelp.com/biz/mcmenamins-high-street-brewery-and-cafe-eugene-2?adjust_creative=2OO9o_S… 168 <df> 3.7 44.0 <chr [1]> $$ 1243 High St. +154… (541) 345-49… 1566. <df [1 × 3]> NA -123. 44.0 breweries
:) 4 YnjnZUfdtpGUjnIBUJ034w gratitude-brewing-eugene Gratitude Brewing https://s3-media4.fl.yelpcdn.com/bphoto/ePtSoPqp0OtUcILhXiH2rQ/o.jpg FALSE https://www.yelp.com/biz/gratitude-brewing-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_camp… 40 <df> 4.5 44.1 <chr [1]> $$ 540 E 8th Ave +154… (541) 654-50… 1316. <df [1 × 3]> NA -123. 44.1 breweries
:) 5 A6Kg53f0zusRQXAlHWHXQA coldfire-brewing-eugene ColdFire Brewing https://s3-media3.fl.yelpcdn.com/bphoto/0v0QYVLFxXvWcV-FoRZhXg/o.jpg FALSE https://www.yelp.com/biz/coldfire-brewing-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campa… 121 <df> 4.7 44.1 <chr [0]> $$ 263 Mill St +154… (541) 636-38… 1699. <df [1 × 3]> NA -123. 44.1 breweries
:) 6 _RcmRae05yeTwZZPh2uFyA claim-52-brewing-eugene Claim 52 Brewing https://s3-media2.fl.yelpcdn.com/bphoto/HVZSke4Mk-xRUbzPPj1FxA/o.jpg FALSE https://www.yelp.com/biz/claim-52-brewing-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campa… 28 <df> 4.4 44.0 <chr [1]> $ 1203 Willamette … +154… (541) 844-01… 1929. <df [1 × 3]> NA -123. 44.0 breweries
:) 7 wSMQ4shfDKOoU4k8RIeu6Q silver-falls-brewery-barrel-house-eugene Silver Falls Brewery Barrel House https://s3-media2.fl.yelpcdn.com/bphoto/9fkRIDslfkyr62iB1LIBbQ/o.jpg FALSE https://www.yelp.com/biz/silver-falls-brewery-barrel-house-eugene?adjust_creative=2OO9o_S_kV__48T… 13 <df> 4.5 44.1 <chr [0]> <NA> 207 E 5th Ave +154… (541) 393-63… 1778. <df [1 × 3]> NA -123. 44.1 breweries
:) 8 lQyzTnVjgCS18l_GocH2_w alesong-on-5th-eugene Alesong on 5th https://s3-media2.fl.yelpcdn.com/bphoto/umqo1ocuKRpSzk_OG5hz9Q/o.jpg FALSE https://www.yelp.com/biz/alesong-on-5th-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaig… 13 <df> 4.1 44.1 <chr [0]> $$ 248 E 5th Ave +154… (541) 505-90… 1768. <df [1 × 3]> NA -123. 44.1 breweries
:) 9 fZHM-3PMaPbuoAYrjGvBkA manifest-bar-and-brewery-eugene Manifest Bar & Brewery https://s3-media2.fl.yelpcdn.com/bphoto/Mm0OdGV1PT7LXi3VWIk7Rg/o.jpg FALSE https://www.yelp.com/biz/manifest-bar-and-brewery-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&u… 1 <df> 5 44.1 <chr [0]> <NA> 740 Willamette St +154… (541) 632-39… 1985. <df [1 × 3]> NA -123. 44.1 breweries
:) 10 646gAhT5sJsaVOvVdg3p9w mcmenamins-high-street-brewery-and-cafe-eugene-2 McMenamins High Street Brewery & Cafe https://s3-media1.fl.yelpcdn.com/bphoto/Po26WIaVCdUfOrkglfF4QA/o.jpg FALSE https://www.yelp.com/biz/mcmenamins-high-street-brewery-and-cafe-eugene-2?adjust_creative=2OO9o_S… 168 <df> 3.7 44.0 <chr [1]> $$ 1243 High St. +154… (541) 345-49… 1921. <df [1 × 3]> NA -123. 44.0 breweries
:) # ℹ 22 more rows
:) # ℹ abbreviated name: ¹​attributes$business_temp_closed
:) # ℹ 11 more variables: coordinates$longitude <dbl>, location$address2 <chr>, $address3 <chr>, $city <chr>, $zip_code <chr>, $country <chr>, $state <chr>, $display_address <list>, attributes$menu_url <chr>, $open24_hours <lgl>, $waitlist_reservation <lgl>
I integrated the two datasets into one.
:) # A tibble: 221 × 21
:) id alias name image_url is_closed url review_count categories rating coordinates$latitude transactions price location$address1 phone display_phone distance business_hours attributes$business_…¹ x y category_manual_input
:) <chr> <chr> <chr> <chr> <lgl> <chr> <int> <list> <dbl> <dbl> <list> <chr> <chr> <chr> <chr> <dbl> <list> <int> <dbl> <dbl> <chr>
:) 1 RW7UfCVzCtjdR8VjARO8AQ pegasus-pizza-eugene-3 Pegasus Pizza https://s3-media1.fl.yelpcdn.com/bphoto/k-7mgGV78S1vfUlimAiIdg/o.jpg FALSE https://www.yelp.com/biz/pegasus-pizza-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign… 82 <df> 3.3 44.1 <chr [2]> $ 4 Oakway Ctr +154… (541) 344-08… 1043. <df [1 × 3]> NA -123. 44.1 pizza
:) 2 -OSaiVv0i9donG_5-Ov-kw mod-pizza-eugene MOD Pizza https://s3-media2.fl.yelpcdn.com/bphoto/jwQAWViCUiO7lJuxRkPdRw/o.jpg FALSE https://www.yelp.com/biz/mod-pizza-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_… 191 <df> 3.5 44.1 <chr [2]> $ 203 Coburg Rd +145… (458) 205-89… 1027. <df [1 × 3]> NA -123. 44.1 pizza
:) 3 yHY_0PIIGfOGms5h-JpD5Q the-o-bar-and-grill-eugene-3 The O Bar & Grill https://s3-media2.fl.yelpcdn.com/bphoto/nmuKD7EbGWHuPKdbcJQSpA/o.jpg FALSE https://www.yelp.com/biz/the-o-bar-and-grill-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_ca… 61 <df> 2.9 44.1 <chr [2]> $ 115 Commons Dr +154… (541) 349-07… 920. <df [1 × 3]> NA -123. 44.1 pizza
:) 4 dghvrys0A_V41ibPXj7yUA papas-pizza-parlor-eugene-7 Papa's Pizza Parlor - Coburg Rd Eugene https://s3-media1.fl.yelpcdn.com/bphoto/6n1wEgF7F9b6oLz6DOThRQ/o.jpg FALSE https://www.yelp.com/biz/papas-pizza-parlor-eugene-7?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_cam… 85 <df> 2.5 44.1 <chr [0]> $$ 1577 Coburg Rd +154… (541) 686-07… 1467. <df [1 × 3]> NA -123. 44.1 pizza
:) 5 YKh7HaUzjizeHrIebkFAAQ papa-murphys-eugene-2 Papa Murphy's https://s3-media1.fl.yelpcdn.com/bphoto/jL-QyMy_7RIeK0E05H6xnQ/o.jpg FALSE https://www.yelp.com/biz/papa-murphys-eugene-2?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=… 24 <df> 3.3 44.1 <chr [1]> $ 1508 Coburg Road +154… (541) 686-66… 1447. <df [0 × 0]> NA -123. 44.1 pizza
:) 6 i1uc9dtkqdbgjjakeTjOxw cork-and-kale-restaurant-eugene Cork & Kale Restaurant https://s3-media2.fl.yelpcdn.com/bphoto/UYHwvthpTSlSe3E3vsQANw/o.jpg FALSE https://www.yelp.com/biz/cork-and-kale-restaurant-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm… 8 <df> 3.1 44.1 <chr [0]> <NA> 2133 Centennial … +154… (541) 342-38… 1288. <df [1 × 3]> NA -123. 44.1 pizza
:) 7 ArX9hk9qcL_OzVJsd4wP3g pieology-pizzeria-springfield-springfield Pieology Pizzeria, Springfield https://s3-media2.fl.yelpcdn.com/bphoto/tNoYjmdjwvsnj-dJ0s2ttw/o.jpg FALSE https://www.yelp.com/biz/pieology-pizzeria-springfield-springfield?adjust_creative=2OO9o_S_kV__48TL… 118 <df> 3.1 44.1 <chr [2]> $ 2860 Gateway Str… +154… (541) 357-43… 924. <df [1 × 3]> NA -123. 44.1 pizza
:) 8 ufwvXcRZdR_0e69QGsUm8Q little-caesars-pizza-springfield-5 Little Caesars Pizza https://s3-media2.fl.yelpcdn.com/bphoto/zuOoNYrMok4sIeeocmphTw/o.jpg FALSE https://www.yelp.com/biz/little-caesars-pizza-springfield-5?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&… 20 <df> 1.7 44.1 <chr [1]> $ 183 Q St +154… (541) 741-36… 1220. <df [1 × 3]> NA -123. 44.1 pizza
:) 9 _ORTNFlJjjm6Wy4TpS-7BA coburg-pizza-company-centennial-springfield-5 Coburg Pizza Company Centennial https://s3-media4.fl.yelpcdn.com/bphoto/BkjR8iTj-i_xP-C2pvffkQ/o.jpg FALSE https://www.yelp.com/biz/coburg-pizza-company-centennial-springfield-5?adjust_creative=2OO9o_S_kV__… 224 <df> 4.2 44.1 <chr [0]> $$ 1710 Centennial … +154… (541) 484-66… 4645. <df [1 × 3]> NA -123. 44.1 pizza
:) 10 SVulg_fxyYsyVBFzYvSeGQ bartolottis-pizza-bistro-springfield-2 Bartolotti's Pizza Bistro https://s3-media2.fl.yelpcdn.com/bphoto/NrHn5F5WqZYRGbbOMsjdUg/o.jpg FALSE https://www.yelp.com/biz/bartolottis-pizza-bistro-springfield-2?adjust_creative=2OO9o_S_kV__48TL7V_… 127 <df> 4.2 44.0 <chr [2]> $$ 330 Main St +154… (541) 505-88… 5171. <df [1 × 3]> NA -123. 44.0 pizza
:) # ℹ 211 more rows
:) # ℹ abbreviated name: ¹​attributes$business_temp_closed
:) # ℹ 11 more variables: coordinates$longitude <dbl>, location$address2 <chr>, $address3 <chr>, $city <chr>, $zip_code <chr>, $country <chr>, $state <chr>, $display_address <list>, attributes$menu_url <chr>, $open24_hours <lgl>, $waitlist_reservation <lgl>
I removed duplicates, which happened due to the spatial overlapps between radii.
:) # A tibble: 66 × 21
:) id alias name image_url is_closed url review_count categories rating coordinates$latitude transactions price location$address1 phone display_phone distance business_hours attributes$business_…¹ x y category_manual_input
:) <chr> <chr> <chr> <chr> <lgl> <chr> <int> <list> <dbl> <dbl> <list> <chr> <chr> <chr> <chr> <dbl> <list> <int> <dbl> <dbl> <chr>
:) 1 RW7UfCVzCtjdR8VjARO8AQ pegasus-pizza-eugene-3 Pegasus Pizza https://s3-media1.fl.yelpcdn.com/bphoto/k-7mgGV78S1vfUlimAiIdg/o.jpg FALSE https://www.yelp.com/biz/pegasus-pizza-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign… 82 <df> 3.3 44.1 <chr [2]> $ 4 Oakway Ctr +154… (541) 344-08… 1043. <df [1 × 3]> NA -123. 44.1 pizza
:) 2 -OSaiVv0i9donG_5-Ov-kw mod-pizza-eugene MOD Pizza https://s3-media2.fl.yelpcdn.com/bphoto/jwQAWViCUiO7lJuxRkPdRw/o.jpg FALSE https://www.yelp.com/biz/mod-pizza-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=yelp_… 191 <df> 3.5 44.1 <chr [2]> $ 203 Coburg Rd +145… (458) 205-89… 1027. <df [1 × 3]> NA -123. 44.1 pizza
:) 3 yHY_0PIIGfOGms5h-JpD5Q the-o-bar-and-grill-eugene-3 The O Bar & Grill https://s3-media2.fl.yelpcdn.com/bphoto/nmuKD7EbGWHuPKdbcJQSpA/o.jpg FALSE https://www.yelp.com/biz/the-o-bar-and-grill-eugene-3?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_ca… 61 <df> 2.9 44.1 <chr [2]> $ 115 Commons Dr +154… (541) 349-07… 920. <df [1 × 3]> NA -123. 44.1 pizza
:) 4 dghvrys0A_V41ibPXj7yUA papas-pizza-parlor-eugene-7 Papa's Pizza Parlor - Coburg Rd Eugene https://s3-media1.fl.yelpcdn.com/bphoto/6n1wEgF7F9b6oLz6DOThRQ/o.jpg FALSE https://www.yelp.com/biz/papas-pizza-parlor-eugene-7?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_cam… 85 <df> 2.5 44.1 <chr [0]> $$ 1577 Coburg Rd +154… (541) 686-07… 1467. <df [1 × 3]> NA -123. 44.1 pizza
:) 5 YKh7HaUzjizeHrIebkFAAQ papa-murphys-eugene-2 Papa Murphy's https://s3-media1.fl.yelpcdn.com/bphoto/jL-QyMy_7RIeK0E05H6xnQ/o.jpg FALSE https://www.yelp.com/biz/papa-murphys-eugene-2?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_campaign=… 24 <df> 3.3 44.1 <chr [1]> $ 1508 Coburg Road +154… (541) 686-66… 1447. <df [0 × 0]> NA -123. 44.1 pizza
:) 6 i1uc9dtkqdbgjjakeTjOxw cork-and-kale-restaurant-eugene Cork & Kale Restaurant https://s3-media2.fl.yelpcdn.com/bphoto/UYHwvthpTSlSe3E3vsQANw/o.jpg FALSE https://www.yelp.com/biz/cork-and-kale-restaurant-eugene?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm… 8 <df> 3.1 44.1 <chr [0]> <NA> 2133 Centennial … +154… (541) 342-38… 1288. <df [1 × 3]> NA -123. 44.1 pizza
:) 7 ArX9hk9qcL_OzVJsd4wP3g pieology-pizzeria-springfield-springfield Pieology Pizzeria, Springfield https://s3-media2.fl.yelpcdn.com/bphoto/tNoYjmdjwvsnj-dJ0s2ttw/o.jpg FALSE https://www.yelp.com/biz/pieology-pizzeria-springfield-springfield?adjust_creative=2OO9o_S_kV__48TL… 118 <df> 3.1 44.1 <chr [2]> $ 2860 Gateway Str… +154… (541) 357-43… 924. <df [1 × 3]> NA -123. 44.1 pizza
:) 8 ufwvXcRZdR_0e69QGsUm8Q little-caesars-pizza-springfield-5 Little Caesars Pizza https://s3-media2.fl.yelpcdn.com/bphoto/zuOoNYrMok4sIeeocmphTw/o.jpg FALSE https://www.yelp.com/biz/little-caesars-pizza-springfield-5?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&… 20 <df> 1.7 44.1 <chr [1]> $ 183 Q St +154… (541) 741-36… 1220. <df [1 × 3]> NA -123. 44.1 pizza
:) 9 _ORTNFlJjjm6Wy4TpS-7BA coburg-pizza-company-centennial-springfield-5 Coburg Pizza Company Centennial https://s3-media4.fl.yelpcdn.com/bphoto/BkjR8iTj-i_xP-C2pvffkQ/o.jpg FALSE https://www.yelp.com/biz/coburg-pizza-company-centennial-springfield-5?adjust_creative=2OO9o_S_kV__… 224 <df> 4.2 44.1 <chr [0]> $$ 1710 Centennial … +154… (541) 484-66… 4645. <df [1 × 3]> NA -123. 44.1 pizza
:) 10 SVulg_fxyYsyVBFzYvSeGQ bartolottis-pizza-bistro-springfield-2 Bartolotti's Pizza Bistro https://s3-media2.fl.yelpcdn.com/bphoto/NrHn5F5WqZYRGbbOMsjdUg/o.jpg FALSE https://www.yelp.com/biz/bartolottis-pizza-bistro-springfield-2?adjust_creative=2OO9o_S_kV__48TL7V_… 127 <df> 4.2 44.0 <chr [2]> $$ 330 Main St +154… (541) 505-88… 5171. <df [1 × 3]> NA -123. 44.0 pizza
:) # ℹ 56 more rows
:) # ℹ abbreviated name: ¹​attributes$business_temp_closed
:) # ℹ 11 more variables: coordinates$longitude <dbl>, location$address2 <chr>, $address3 <chr>, $city <chr>, $zip_code <chr>, $country <chr>, $state <chr>, $display_address <list>, attributes$menu_url <chr>, $open24_hours <lgl>, $waitlist_reservation <lgl>
The current dataset is just a tibble, not a spatial object. Using the
x and y coordinates, I made it into an sf
object.
yelp_result_all_sf <- yelp_result_all %>%
filter(!is.na(x) & !is.na(y)) %>%
mutate(x_coord = x,
y_coord = y,) %>%
st_as_sf(coords = c("x", "y"), crs = 4326)
yelp_result_all_sf
:) Simple feature collection with 66 features and 21 fields
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44 xmax: -123 ymax: 44.1
:) Geodetic CRS: WGS 84
:) # A tibble: 66 × 22
:) id alias name image_url is_closed url review_count categories rating coordinates$latitude transactions price location$address1 phone display_phone distance business_hours attributes$business_…¹ category_manual_input x_coord y_coord geometry
:) * <chr> <chr> <chr> <chr> <lgl> <chr> <int> <list> <dbl> <dbl> <list> <chr> <chr> <chr> <chr> <dbl> <list> <int> <chr> <dbl> <dbl> <POINT [°]>
:) 1 RW7UfCVzCtjdR8VjARO8AQ pegasus-pizza-eugene-3 Pegasus Pizza https://s3-media1.fl.yelpcdn.com/bphoto/k-7mgGV78S1vfUlimAiIdg/o.jpg FALSE https://www.yelp.com/biz/pegasus-pizza-eugene-3?adjust_creative=2OO9o… 82 <df> 3.3 44.1 <chr [2]> $ 4 Oakway Ctr +154… (541) 344-08… 1043. <df [1 × 3]> NA pizza -123. 44.1 (-123 44.1)
:) 2 -OSaiVv0i9donG_5-Ov-kw mod-pizza-eugene MOD Pizza https://s3-media2.fl.yelpcdn.com/bphoto/jwQAWViCUiO7lJuxRkPdRw/o.jpg FALSE https://www.yelp.com/biz/mod-pizza-eugene?adjust_creative=2OO9o_S_kV_… 191 <df> 3.5 44.1 <chr [2]> $ 203 Coburg Rd +145… (458) 205-89… 1027. <df [1 × 3]> NA pizza -123. 44.1 (-123 44.1)
:) 3 yHY_0PIIGfOGms5h-JpD5Q the-o-bar-and-grill-eugene-3 The O Bar & Grill https://s3-media2.fl.yelpcdn.com/bphoto/nmuKD7EbGWHuPKdbcJQSpA/o.jpg FALSE https://www.yelp.com/biz/the-o-bar-and-grill-eugene-3?adjust_creative… 61 <df> 2.9 44.1 <chr [2]> $ 115 Commons Dr +154… (541) 349-07… 920. <df [1 × 3]> NA pizza -123. 44.1 (-123 44.1)
:) 4 dghvrys0A_V41ibPXj7yUA papas-pizza-parlor-eugene-7 Papa's Pizza Parlor - Coburg Rd Eugene https://s3-media1.fl.yelpcdn.com/bphoto/6n1wEgF7F9b6oLz6DOThRQ/o.jpg FALSE https://www.yelp.com/biz/papas-pizza-parlor-eugene-7?adjust_creative=… 85 <df> 2.5 44.1 <chr [0]> $$ 1577 Coburg Rd +154… (541) 686-07… 1467. <df [1 × 3]> NA pizza -123. 44.1 (-123 44.1)
:) 5 YKh7HaUzjizeHrIebkFAAQ papa-murphys-eugene-2 Papa Murphy's https://s3-media1.fl.yelpcdn.com/bphoto/jL-QyMy_7RIeK0E05H6xnQ/o.jpg FALSE https://www.yelp.com/biz/papa-murphys-eugene-2?adjust_creative=2OO9o_… 24 <df> 3.3 44.1 <chr [1]> $ 1508 Coburg Road +154… (541) 686-66… 1447. <df [0 × 0]> NA pizza -123. 44.1 (-123 44.1)
:) 6 i1uc9dtkqdbgjjakeTjOxw cork-and-kale-restaurant-eugene Cork & Kale Restaurant https://s3-media2.fl.yelpcdn.com/bphoto/UYHwvthpTSlSe3E3vsQANw/o.jpg FALSE https://www.yelp.com/biz/cork-and-kale-restaurant-eugene?adjust_creat… 8 <df> 3.1 44.1 <chr [0]> <NA> 2133 Centennial … +154… (541) 342-38… 1288. <df [1 × 3]> NA pizza -123. 44.1 (-123 44.1)
:) 7 ArX9hk9qcL_OzVJsd4wP3g pieology-pizzeria-springfield-springfield Pieology Pizzeria, Springfield https://s3-media2.fl.yelpcdn.com/bphoto/tNoYjmdjwvsnj-dJ0s2ttw/o.jpg FALSE https://www.yelp.com/biz/pieology-pizzeria-springfield-springfield?ad… 118 <df> 3.1 44.1 <chr [2]> $ 2860 Gateway Str… +154… (541) 357-43… 924. <df [1 × 3]> NA pizza -123. 44.1 (-123 44.1)
:) 8 ufwvXcRZdR_0e69QGsUm8Q little-caesars-pizza-springfield-5 Little Caesars Pizza https://s3-media2.fl.yelpcdn.com/bphoto/zuOoNYrMok4sIeeocmphTw/o.jpg FALSE https://www.yelp.com/biz/little-caesars-pizza-springfield-5?adjust_cr… 20 <df> 1.7 44.1 <chr [1]> $ 183 Q St +154… (541) 741-36… 1220. <df [1 × 3]> NA pizza -123. 44.1 (-123 44.1)
:) 9 _ORTNFlJjjm6Wy4TpS-7BA coburg-pizza-company-centennial-springfield-5 Coburg Pizza Company Centennial https://s3-media4.fl.yelpcdn.com/bphoto/BkjR8iTj-i_xP-C2pvffkQ/o.jpg FALSE https://www.yelp.com/biz/coburg-pizza-company-centennial-springfield-… 224 <df> 4.2 44.1 <chr [0]> $$ 1710 Centennial … +154… (541) 484-66… 4645. <df [1 × 3]> NA pizza -123. 44.1 (-123 44.1)
:) 10 SVulg_fxyYsyVBFzYvSeGQ bartolottis-pizza-bistro-springfield-2 Bartolotti's Pizza Bistro https://s3-media2.fl.yelpcdn.com/bphoto/NrHn5F5WqZYRGbbOMsjdUg/o.jpg FALSE https://www.yelp.com/biz/bartolottis-pizza-bistro-springfield-2?adjus… 127 <df> 4.2 44.0 <chr [2]> $$ 330 Main St +154… (541) 505-88… 5171. <df [1 × 3]> NA pizza -123. 44.0 (-123 44)
:) # ℹ 56 more rows
:) # ℹ abbreviated name: ¹​attributes$business_temp_closed
:) # ℹ 11 more variables: coordinates$longitude <dbl>, location$address2 <chr>, $address3 <chr>, $city <chr>, $zip_code <chr>, $country <chr>, $state <chr>, $display_address <list>, attributes$menu_url <chr>, $open24_hours <lgl>, $waitlist_reservation <lgl>
I visualized the Pizza and Brewery POIs.
tmap_mode('view')
tm_shape(tract_spring) +
tm_polygons(col = "hhincomeE", alpha=0.5) +
tm_shape(spring) +
tm_borders(col="black", lwd=1.5) +
tm_shape(yelp_result_all_sf) +
tm_dots(col = "category_manual_input", palette = c("red", "blue")) +
tm_layout(
legend.title.size = 4,
legend.text.size = 5,
legend.position = c("right","bottom"),
main.title = "City of Springfield and 23 Census Tracts", main.title.position = "left", main.title.size = 7
) +
tm_layout(frame = FALSE)
I excluded POIs that are outside the boundary of Springfield. POIs outside the boundary were found because the radius of census tract often exceeds the city boundary.
yelp_result_all_sf_inspring <- yelp_result_all_sf[spring, ] %>%
relocate(id, name, category_manual_input, x_coord, y_coord, geometry)
yelp_result_all_sf_inspring
:) Simple feature collection with 22 features and 21 fields
:) Geometry type: POINT
:) Dimension: XY
:) Bounding box: xmin: -123 ymin: 44 xmax: -123 ymax: 44.1
:) Geodetic CRS: WGS 84
:) # A tibble: 22 × 22
:) id name category_manual_input x_coord y_coord geometry alias image_url is_closed url review_count categories rating coordinates$latitude transactions price location$address1 phone display_phone distance business_hours attributes$business_…¹
:) <chr> <chr> <chr> <dbl> <dbl> <POINT [°]> <chr> <chr> <lgl> <chr> <int> <list> <dbl> <dbl> <list> <chr> <chr> <chr> <chr> <dbl> <list> <int>
:) 1 ArX9hk9qcL_OzVJsd4wP3g Pieology Pizzeria, Springfield pizza -123. 44.1 (-123 44.1) pieology-pizzeria-springfield-springfield https://s3-media2.fl.yelpcdn.com/bphoto/tNoYjmdjwvsnj-dJ0s2ttw/o.jpg FALSE https://www.yelp.com/biz/pieology-pizzeria-springfield-springfield?adjust_creative=2OO9o_S… 118 <df> 3.1 44.1 <chr [2]> $ 2860 Gateway Str… +154… (541) 357-43… 924. <df [1 × 3]> NA
:) 2 ufwvXcRZdR_0e69QGsUm8Q Little Caesars Pizza pizza -123. 44.1 (-123 44.1) little-caesars-pizza-springfield-5 https://s3-media2.fl.yelpcdn.com/bphoto/zuOoNYrMok4sIeeocmphTw/o.jpg FALSE https://www.yelp.com/biz/little-caesars-pizza-springfield-5?adjust_creative=2OO9o_S_kV__48… 20 <df> 1.7 44.1 <chr [1]> $ 183 Q St +154… (541) 741-36… 1220. <df [1 × 3]> NA
:) 3 _ORTNFlJjjm6Wy4TpS-7BA Coburg Pizza Company Centennial pizza -123. 44.1 (-123 44.1) coburg-pizza-company-centennial-springfield-5 https://s3-media4.fl.yelpcdn.com/bphoto/BkjR8iTj-i_xP-C2pvffkQ/o.jpg FALSE https://www.yelp.com/biz/coburg-pizza-company-centennial-springfield-5?adjust_creative=2OO… 224 <df> 4.2 44.1 <chr [0]> $$ 1710 Centennial … +154… (541) 484-66… 4645. <df [1 × 3]> NA
:) 4 SVulg_fxyYsyVBFzYvSeGQ Bartolotti's Pizza Bistro pizza -123. 44.0 (-123 44) bartolottis-pizza-bistro-springfield-2 https://s3-media2.fl.yelpcdn.com/bphoto/NrHn5F5WqZYRGbbOMsjdUg/o.jpg FALSE https://www.yelp.com/biz/bartolottis-pizza-bistro-springfield-2?adjust_creative=2OO9o_S_kV… 127 <df> 4.2 44.0 <chr [2]> $$ 330 Main St +154… (541) 505-88… 5171. <df [1 × 3]> NA
:) 5 QIdf70NMFF27TxkPevj0vQ R Pizza pizza -123. 44.1 (-123 44.1) r-pizza-springfield https://s3-media3.fl.yelpcdn.com/bphoto/KaSyZ8dhNa_0GkKgS3E7fg/o.jpg FALSE https://www.yelp.com/biz/r-pizza-springfield?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&utm_ca… 63 <df> 4.5 44.1 <chr [2]> <NA> 1406 Mohawk Blvd +154… (541) 636-38… 4887. <df [1 × 3]> NA
:) 6 CyuS3d7vq3Q3vj2w5u9Oxg Mezza Luna Pizzeria pizza -123. 44.0 (-123 44) mezza-luna-pizzeria-springfield https://s3-media2.fl.yelpcdn.com/bphoto/d4e9AY6FxKK9lIA2Hx5wRQ/o.jpg FALSE https://www.yelp.com/biz/mezza-luna-pizzeria-springfield?adjust_creative=2OO9o_S_kV__48TL7… 62 <df> 4.1 44.0 <chr [2]> $ 115 S 5th St +154… (541) 653-86… 5022. <df [1 × 3]> NA
:) 7 rptyhCBlnb-1zy-cSUaA4g Papa's Pizza Parlor pizza -123. 44.0 (-123 44) papas-pizza-parlor-springfield-3 https://s3-media2.fl.yelpcdn.com/bphoto/-6D0Fm1UgT62DUKyqJPiXw/o.jpg FALSE https://www.yelp.com/biz/papas-pizza-parlor-springfield-3?adjust_creative=2OO9o_S_kV__48TL… 110 <df> 2.6 44.0 <chr [1]> $$ 4011 Main St +154… (541) 741-11… 2591. <df [1 × 3]> NA
:) 8 9vLvm7L9NaVV1-OF1D5a-Q Joey's Pizza pizza -123. 44.0 (-123 44) joeys-pizza-springfield https://s3-media2.fl.yelpcdn.com/bphoto/5d4vnjmF-hejmLT_X5s2Qw/o.jpg FALSE https://www.yelp.com/biz/joeys-pizza-springfield?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&ut… 104 <df> 3.5 44.0 <chr [1]> $$ 1498 S A St +154… (541) 746-69… 3911. <df [1 × 3]> NA
:) 9 9Dx58Yf-7tG19e9kqeOqNw Abby's Legendary Pizza pizza -123. 44.1 (-123 44.1) abbys-legendary-pizza-springfield https://s3-media4.fl.yelpcdn.com/bphoto/3Sp6COIuehmLLEiX-Mhvew/o.jpg FALSE https://www.yelp.com/biz/abbys-legendary-pizza-springfield?adjust_creative=2OO9o_S_kV__48T… 32 <df> 2.4 44.1 <chr [1]> $$ 2053 Olympic St +154… (541) 747-44… 4754. <df [1 × 3]> NA
:) 10 EF3EGnuqJ6lrMScCoEIVEw MOD Pizza pizza -123. 44.1 (-123 44.1) mod-pizza-springfield-2 https://s3-media4.fl.yelpcdn.com/bphoto/ACCkG44VseKY08t_MZQ4RQ/o.jpg FALSE https://www.yelp.com/biz/mod-pizza-springfield-2?adjust_creative=2OO9o_S_kV__48TL7V_Q1g&ut… 14 <df> 3.5 44.1 <chr [2]> <NA> 1820 Olympic St +145… (458) 201-54… 4902. <df [1 × 3]> NA
:) # ℹ 12 more rows
:) # ℹ abbreviated name: ¹​attributes$business_temp_closed
:) # ℹ 11 more variables: coordinates$longitude <dbl>, location$address2 <chr>, $address3 <chr>, $city <chr>, $zip_code <chr>, $country <chr>, $state <chr>, $display_address <list>, attributes$menu_url <chr>, $open24_hours <lgl>, $waitlist_reservation <lgl>
I visualized again. After removing duplicates and out-of-the-boundary POIs, I had only 2 breweries and 20 pizza restaurants in my final dataset. The following are the few findings: - There are much fewer breweries than pizza restaurants, probably because people visit breweries occassionaly. - While pizza restaurants are clustered in some local areas, most neighborhoods within the city boundary has quite a good access to pizza restaurants. This might be because pizza is a daily food and mostly has a reasonable price. - Notably, there is one brewery and two pizza restaurants very close to each other. While I need more evidence, pizza and beers may a good complementary to each other.
tmap_mode('view')
tm_shape(tract_spring) +
tm_polygons(col = "hhincomeE", alpha=0.5) +
tm_shape(spring) +
tm_borders(col="black", lwd=1.5) +
tm_shape(yelp_result_all_sf_inspring) +
tm_dots(col = "category_manual_input", palette = c("red", "blue")) +
tm_layout(
legend.title.size = 4,
legend.text.size = 5,
legend.position = c("right","bottom"),
main.title = "City of Springfield and 23 Census Tracts", main.title.position = "left", main.title.size = 7
) +
tm_layout(frame = FALSE)