#install.packages("foreign")
#install.packages("ggmap")
library(foreign)
library(ggplot2)
## Registered S3 methods overwritten by 'ggplot2':
## method from
## [.quosures rlang
## c.quosures rlang
## print.quosures rlang
library(ggmap)
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
dataset = read.dbf("C:/Users/HPi/OneDrive - HP Inc/Pradosh/Personal/Harrisburg/Course 512/pennsylv/pennsylv.dbf")
register_google(key="AIzaSyAG3wwHk_OjTT8lI3syS5g4tDufNM9wNX8")
Using the spatial visualization techniques, explore this data set on Pennsylvania hospitals (http://www.arcgis.com/home/item.html?id=eccee5dfe01e4c4283c9be0cfc596882). Create a series of 5 maps that highlight spatial differences in hospital service coverage for the state of PA.
To help you in getting the data imported into R
, I have included the code below:
To import the data I use the foreign
package, if you do not have it than be sure to install it prior to testing the code.
#The map below shows the distribution of hospitals with Kidney Transplant. As seen from the map, we see that these hospitals are concenrated in the area of Philadelphia and spread across Pittsburg.Some of these are spread out in some cities towards the west of Philadelphia.
data_kidney_trasplant <- subset(dataset, kidney_tra == "Y")
qmplot(x, y, data = data_kidney_trasplant, legend = "none", colour= I('red'), mapcolor = "color", extent = "panel",darken = 0.1, main = "Hospitals with Kidney Transplant facility", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'terrain', size = I(1), zoom = 7)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.602731,-77.564336&zoom=7&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
##Map 2
#The map below shows the distribution of hospitals with Liver transplant facilities.Again, a majority of these facilities are concentrated in Pittsburgh and Philadelphia.
data_liver_transplant <- subset(dataset, liver_tran=="Y")
qmplot(x, y, data = data_liver_transplant, legend = "none", colour= I('red'), mapcolor = "color", extent = "panel",darken = 0.1, main = "Hospitals with Liver Transplant facility", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'roadmap', size = I(1), zoom = 7)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.457864,-77.564336&zoom=7&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx
##Map 3
#The map below shows the distribution of hospitals that have Cardiac surgeons.WHile most of the Cardiac surgeons are based out of Philly and Pittsburgh, there are a lot of surgeons that are spread densely around Philly towards immediate north adn west of Philly.
data_cardiac_surgeon = subset(dataset, card_surge=="Y")
qmplot(x, y, data = data_cardiac_surgeon, legend = "none", colour= I('yellow'), mapcolor = "color", extent = "panel",darken = 0.1, main = "Hospitals with Cardiac surgeons", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'hybrid', size = I(1), zoom = 7)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.995052,-77.681596&zoom=7&size=640x640&scale=2&maptype=hybrid&language=en-EN&key=xxx
##Map 4
#The map below shows the distribution of hospitals with helipad facility. There are a huge number of hospitals with hhelipad facility apart from the concentrated areas of Philly and Pittsburgh. THese facilities are uniformly and densly distributed in the heart of Pennsylvania.
data_helipad = subset(dataset, helipad=="Y")
qmplot(x, y, data = data_helipad, legend = "none", colour= I('red'), mapcolor = "color", extent = "panel",darken = 0.1, main = "Hospitals with Helipad facility", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'terrain', size = I(1), zoom = 7)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.942648,-77.681828&zoom=7&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
##Map 5
#The map below shows the distribution of hospitals with optometry capability. WHile Philly adn Pittsburgh have a chunk of these, we see some facilities in Harrisburg, York, Scranton, and along the stretch that connects Philly and Pittsburgh.
data_optometry = subset(dataset, optometry == "Y")
qmplot(x, y, data = data_optometry, legend = "none", colour= I('red'), mapcolor = "color", extent = "panel",darken = 0.1, main = "Hospitals with Optometry capability", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'roadmap', size = I(1), zoom = 7)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.971355,-77.697989&zoom=7&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx