A new IKEA store is going to be placed in the Boston area and this code uses predetermined parameters to create a map of the potential locations for the store. The potential locations must have a median income between 25,000 and 80,000 dollars and a household value between 200,000 and 500,000 dollars. Additionally, the store must be built on open lands, be within 2000 feet of major roads and be at least 200,000 square feet. Utilizing census data, land use information from MassGIS, and data on Boston’s major roads from the US Census Bureau, tidyverse functions are utilized to select potential locations. The locations are then mapped for visualization and analysis of the potential locations.
library(tidyverse)
library(sf)
censustracts <- read_sf("/Users/lorigerstenfeld/Downloads/Lite_SDS/Lite_SDS/CS_07_spatial_case_study_data/Boston_CensusTracts.shp")
landuse <- read_sf("/Users/lorigerstenfeld/Downloads/Lite_SDS/Lite_SDS/CS_07_spatial_case_study_data/Boston_LandUse.shp")
majorroads <- read_sf("/Users/lorigerstenfeld/Downloads/Lite_SDS/Lite_SDS/CS_07_spatial_case_study_data/Boston_MajorRoads.shp")
censustracts2 <- censustracts %>%
filter(Med_Income>25000 & Med_Income<80000) %>%
filter(Med_HouseV>200000 & Med_HouseV<500000)
landuse2 <- landuse %>%
filter(LU05_DESC=='Open Land')
majorroads2 <- majorroads %>%
st_buffer(2000)
sum(!st_is_valid(censustracts2))
## [1] 0
sum(!st_is_valid(landuse2))
## [1] 1
sum(!st_is_valid(majorroads2))
## [1] 0
From these results, we can see that all of the polygons in the census tracts and major roads data sets are valid, however there are 1 polygon in the land use data set is invalid.
landuse3 <- st_make_valid(landuse2)
#check that it worked
sum(!st_is_valid(landuse3))
## [1] 0
Looks like it worked!
intersection <- st_intersection(censustracts2, landuse3, majorroads2) %>%
st_union() %>%
st_cast("POLYGON") %>%
st_as_sf()
intersection$area <- as.numeric(st_area(intersection))
ikea <- intersection %>%
dplyr::filter(area > 200000)
censustracts <- censustracts %>%
filter(Med_Income>1)
#open png
png("/Users/lorigerstenfeld/Downloads/ikeamap.png",
height=1500,
width=1500,
res=150)
#create map
ggplot()+
geom_sf(data=censustracts, aes(fill=Med_Income)) + #mapping median income
scale_fill_distiller(palette="BuPu", name="Median Income")+
geom_sf(data=ikea, fill="red", aes(color="red"))+ #mapping potential sites
scale_color_manual(values="red",
name="Potential IKEA Locations",
labels="Area of Locations Satisfying Requirements")+ #adding potential sites to legend
labs(title="Potential IKEA Locations in Boston, MA",
subtitle="Data from US Census Bureau and MassGIS",
x="Latitude",
y="Longitude") +
theme_classic()+
theme(plot.title = element_text(hjust=0.5, vjust=3),
plot.subtitle=element_text(hjust=0.5, vjust=3)) #centering title and subtitle
#close png
dev.off()
Figure 1: Potential Boston IKEA Locations
The completed analysis allowed for the identification of 20 potential locations for the new Boston IKEA store. As shown by figure 1, most of the potential locations are located in the northeast of Boston, with some in the southeast. Generally, the locations are concentrated in higher-income areas of Boston (colored purple in Figure 1), which verifies the accuracy of the data analysis, as one of the parameters for potential store location was a relatively high median household income. With this data, IKEA representatives can identify their ideal location for a store. They may want to consider the other stores surrounding these potential locations and gauge public interest to determine a final location for the new IKEA store.