Loading google_poi_data.rds from last project.
City: Paradise Valley, Arizona Place types: Bus Station, Transit Station
poi_data <- readRDS(here::here("google_poi_data.rds"))
rows_before <- nrow(poi_data)
poi_data <- poi_data %>% distinct()
rows_after <- nrow(poi_data)
print(paste0("Before: ", rows_before))
## [1] "Before: 347"
print(paste0("After: ", rows_after))
## [1] "After: 218"
Collapse the places.types column so that each element contains a single string value. If your data includes list-columns other than places.types, handle them appropriately while ensuring each row still represents a unique POI.
poi_data <- poi_data %>%
mutate(places.types = map_chr(places.types, ~ paste(.x, collapse = ","), .default = NA))
#Handle missing values Remove rows with NA values in columns that you consider important. Explain your reasoning. Report how many rows remain after this step.
rows_before <- nrow(poi_data)
poi_data <- poi_data %>%
filter(!is.na(places.displayName.text),
!is.na(places.formattedAddress),
!is.na(places.location.latitude),
!is.na(places.location.longitude))
rows_after <- nrow(poi_data)
print(paste0("Before: ", rows_before))
## [1] "Before: 218"
print(paste0("After: ", rows_after))
## [1] "After: 218"
Remove rows that fall outside the city boundary. Show how the number of rows changes after filtering.
pv <- tigris::places("AZ", progress_bar = FALSE) %>%
filter(NAME == 'Paradise Valley') %>%
st_transform(4326)
## Retrieving data for the year 2024
poi_sf <- poi_data %>%
st_as_sf(coords=c("places.location.longitude", "places.location.latitude"),
crs = 4326)
poi_sf_in <- poi_sf[pv, ]
print(paste0("Before: ", nrow(poi_sf)))
## [1] "Before: 218"
print(paste0("After: ", nrow(poi_sf_in)))
## [1] "After: 27"
print(head(poi_sf_in, 10))
## Simple feature collection with 10 features and 7 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -111.9775 ymin: 33.53041 xmax: -111.926 ymax: 33.58256
## Geodetic CRS: WGS 84
## places.id
## 19 ChIJt25m78B0K4cR1PuXje3O9ys
## 35 ChIJteAhXL8MK4cRPwpk6tJneCY
## 36 ChIJp-6VUL8MK4cRW0UqKqQd5M4
## 44 ChIJBZGBKXJzK4cRCDEdmA79Dpo
## 45 ChIJRxgPzwxzK4cR_lIm0UNhAtc
## 46 ChIJQR_IwgxzK4cR1erokIGWz0g
## 51 ChIJg3XRLzgLK4cRWavkRiSEQxo
## 54 ChIJQ1zM0DgLK4cRoNhAlPeUTxs
## 56 ChIJ7VqlXDYLK4cRWTEGucPHedg
## 69 ChIJV1JEJLYMK4cR8PaFWLHj6Dw
## places.types
## 19 bus_stop,transit_station,point_of_interest,establishment
## 35 bus_stop,transit_station,point_of_interest,establishment
## 36 transit_station,point_of_interest,establishment
## 44 bus_stop,transit_station,point_of_interest,establishment
## 45 bus_stop,transit_station,point_of_interest,establishment
## 46 transit_station,point_of_interest,establishment
## 51 bus_station,transit_station,point_of_interest,establishment
## 54 bus_stop,transit_station,point_of_interest,establishment
## 56 bus_stop,transit_station,point_of_interest,establishment
## 69 bus_stop,transit_station,point_of_interest,establishment
## places.formattedAddress places.rating places.userRatingCount
## 19 Paradise Valley, AZ 85253, USA NA NA
## 35 Paradise Valley, AZ 85253, USA NA NA
## 36 Paradise Valley, AZ 85253, USA NA NA
## 44 Paradise Valley, AZ 85253, USA NA NA
## 45 Paradise Valley, AZ 85253, USA NA NA
## 46 Paradise Valley Village, AZ, USA NA NA
## 51 Paradise Valley, AZ 85253, USA NA NA
## 54 Paradise Valley, AZ 85258, USA NA NA
## 56 Paradise Valley, AZ 85253, USA NA NA
## 69 Paradise Valley, AZ 85253, USA 5 1
## places.displayName.text places.displayName.languageCode
## 19 Scottsdale Rd & Mountain View Rd en
## 35 Tatum Bl & Lincoln Dr en
## 36 Tatum Blvd & Lincoln Dr en
## 44 Shea Bl & 51st Pl en
## 45 Shea Bl & Tatum Bl en
## 46 Tatum Blvd & Shea Blvd en
## 51 Scottsdale Rd & Cheney Dr en
## 54 Scottsdale Rd & Hummingbird Ln en
## 56 Scottsdale Rd & McCormick Pkwy en
## 69 Tatum Bl & Quartz Mountain Rd en
## geometry
## 19 POINT (-111.9263 33.57455)
## 35 POINT (-111.9758 33.53041)
## 36 POINT (-111.9756 33.53079)
## 44 POINT (-111.9703 33.58256)
## 45 POINT (-111.9771 33.58253)
## 46 POINT (-111.9775 33.58234)
## 51 POINT (-111.926 33.54551)
## 54 POINT (-111.926 33.5412)
## 56 POINT (-111.9261 33.54961)
## 69 POINT (-111.9755 33.54041)
#Explore and report findings
Write about at least four interesting observations you discovered (maximum 200 words). Include plots or maps if helpful.
poi_sf_in_new <- poi_sf_in %>%
mutate(type_simple = case_when(
grepl("bus_stop", places.types) ~ "Bus Stop",
grepl("transit_station", places.types) ~ "Transit Station",
TRUE ~ "Other"
))
tmap_mode("view")
## ℹ tmap mode set to "view".
tm_shape(pv) + tm_borders(col = "blue", lwd = 2) +
tm_shape(poi_sf_in_new) +
tm_dots(fill = "type_simple", size = 0.5,
fill.scale = tm_scale(values = c("Bus Stop" = "red",
"Transit Station" = "purple")))
counts <- poi_sf_in_new %>%
st_drop_geometry() %>%
count(type_simple)
There seems to be not a lot of transit stations in Paradise Valley, with most of the bus or transit stations being on the edge corridors and main streets. 27 transit spots for a city the size of Paradise Valley seems to be low but let’s see per capita.
bg <- suppressMessages(
tidycensus::get_acs(geography = "block group",
state = "AZ",
county = "Maricopa",
variables = c(totalpop = "B01001_001"),
year = 2023,
survey = "acs5",
geometry = TRUE,
output = "wide"
)
)
## 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.
## | | | 0% | |= | 1% | |== | 2% | |== | 3% | |=== | 4% | |=== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========= | 14% | |========== | 14% | |=========== | 15% | |============ | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |=================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |======================= | 33% | |======================== | 34% | |========================= | 35% | |========================= | 36% | |========================== | 37% | |========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================== | 42% | |============================== | 43% | |=============================== | 44% | |=============================== | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |====================================== | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================= | 71% | |================================================== | 71% | |=================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |====================================================== | 78% | |======================================================= | 78% | |======================================================== | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |=========================================================== | 85% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |=============================================================== | 91% | |================================================================ | 92% | |================================================================= | 92% | |================================================================= | 93% | |================================================================== | 94% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |==================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 99% | |======================================================================| 100%
bg <- st_transform(bg, 4326)
pv <- st_transform(pv, 4326)
pv_bg <- bg[pv,]
pv_pop <- sum(pv_bg$totalpopE, na.rm = TRUE)
pv_pop
## [1] 34196
counts <- counts %>%
mutate(per_capita = n / pv_pop)
counts
## type_simple n per_capita
## 1 Bus Stop 22 0.0006433501
## 2 Transit Station 5 0.0001462159
That seems to be an extremely low amount of transit systems compared to the population of people. That being said Paradise Valley seems to be a mostly residential community, which I guess makes sense as to why the transit stations are moslty on the major roads but it also makes transit extremely accessible to those who live in these neighborhoods who may not want to walk a lot in the extreme heat that Arizona tends to face.
I originally filtered the data to remove all of the rows where there were no ratings but that only yielded me with 3 transit stops that were within PV boundaries.
Bus stops also make up the majority of the transit stations in Paradise Valley which also indicates that they only have low-capacity transit options available, not as much of a public transportation infrastructure exists in Paradise Valley.