# Load required packages
library(sf)
library(tidyverse)
library(tigris)
library(tidycensus)
library(scales)
library(patchwork)
library(here)
getwd()[1] "C:/Users/bhanu/OneDrive/Desktop/Post Grad Work/Sem 2/PPA/PortfolioPPA/labs/lab_2"
# Load spatial data
hospitals <- st_read(here("data/hospitals.geojson"))Reading layer `hospitals' from data source
`C:\Users\bhanu\OneDrive\Desktop\Post Grad Work\Sem 2\PPA\PortfolioPPA\data\hospitals.geojson'
using driver `GeoJSON'
Simple feature collection with 223 features and 11 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: -80.49621 ymin: 39.75163 xmax: -74.86704 ymax: 42.13403
Geodetic CRS: WGS 84
pa_tracts <- tracts(state = "PA", cb = TRUE)
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 3%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|====== | 8%
|
|====== | 9%
|
|======= | 10%
|
|======== | 11%
|
|========= | 12%
|
|========= | 13%
|
|========== | 14%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============= | 18%
|
|============= | 19%
|
|============== | 20%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 23%
|
|================= | 24%
|
|================= | 25%
|
|================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 29%
|
|===================== | 30%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|========================== | 38%
|
|=========================== | 39%
|
|============================ | 40%
|
|============================ | 41%
|
|============================= | 42%
|
|============================== | 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%
|
|================================================== | 72%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 79%
|
|======================================================== | 80%
|
|======================================================== | 81%
|
|========================================================= | 81%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 87%
|
|============================================================== | 88%
|
|=============================================================== | 89%
|
|=============================================================== | 90%
|
|================================================================ | 91%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 100%
pa_counties <- st_read(here("data/Pennsylvania_County_Boundaries.shp"))Reading layer `Pennsylvania_County_Boundaries' from data source
`C:\Users\bhanu\OneDrive\Desktop\Post Grad Work\Sem 2\PPA\PortfolioPPA\data\Pennsylvania_County_Boundaries.shp'
using driver `ESRI Shapefile'
Simple feature collection with 67 features and 19 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -8963377 ymin: 4825316 xmax: -8314404 ymax: 5201413
Projected CRS: WGS 84 / Pseudo-Mercator
# Check that all data loaded correctly
pa_countiesSimple feature collection with 67 features and 19 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -8963377 ymin: 4825316 xmax: -8314404 ymax: 5201413
Projected CRS: WGS 84 / Pseudo-Mercator
First 10 features:
OBJECTID MSLINK COUNTY_NAM COUNTY_NUM FIPS_COUNT COUNTY_ARE COUNTY_PER
1 336 46 MONTGOMERY 46 091 <NA> <NA>
2 337 8 BRADFORD 08 015 <NA> <NA>
3 338 9 BUCKS 09 017 <NA> <NA>
4 339 58 TIOGA 58 117 <NA> <NA>
5 340 59 UNION 59 119 <NA> <NA>
6 341 60 VENANGO 60 121 <NA> <NA>
7 342 62 WASHINGTON 62 125 <NA> <NA>
8 343 63 WAYNE 63 127 <NA> <NA>
9 344 42 MCKEAN 42 083 <NA> <NA>
10 345 43 MERCER 43 085 <NA> <NA>
NUMERIC_LA COUNTY_N_1 AREA_SQ_MI SOUND SPREAD_SHE IMAGE_NAME NOTE_FILE VIDEO
1 5 46 487.4271 <NA> <NA> poll.bmp <NA> <NA>
2 2 8 1161.3379 <NA> <NA> poll.bmp <NA> <NA>
3 5 9 622.0836 <NA> <NA> poll.bmp <NA> <NA>
4 2 58 1137.2480 <NA> <NA> poll.bmp <NA> <NA>
5 2 59 319.1893 <NA> <NA> poll.bmp <NA> <NA>
6 3 60 683.3676 <NA> <NA> poll.bmp <NA> <NA>
7 1 62 862.1077 <NA> <NA> poll.bmp <NA> <NA>
8 2 63 750.8286 <NA> <NA> poll.bmp <NA> <NA>
9 1 42 985.2700 <NA> <NA> poll.bmp <NA> <NA>
10 3 43 682.3598 <NA> <NA> poll.bmp <NA> <NA>
DISTRICT_N PA_CTY_COD MAINT_CTY_ DISTRICT_O geometry
1 06 46 4 6-4 MULTIPOLYGON (((-8398884 48...
2 03 08 9 3-9 MULTIPOLYGON (((-8558633 51...
3 06 09 1 6-1 MULTIPOLYGON (((-8367360 49...
4 03 59 7 3-7 MULTIPOLYGON (((-8558633 51...
5 03 60 8 3-8 MULTIPOLYGON (((-8562865 49...
6 01 61 5 1-5 MULTIPOLYGON (((-8870781 50...
7 12 63 4 12-4 MULTIPOLYGON (((-8935296 48...
8 04 64 6 4-6 MULTIPOLYGON (((-8368003 50...
9 02 42 5 2-5 MULTIPOLYGON (((-8705967 51...
10 01 43 4 1-4 MULTIPOLYGON (((-8956031 50...
pa_tractsSimple feature collection with 3445 features and 13 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -80.51989 ymin: 39.7198 xmax: -74.68952 ymax: 42.26986
Geodetic CRS: NAD83
First 10 features:
STATEFP COUNTYFP TRACTCE GEOIDFQ GEOID NAME
1 42 001 031101 1400000US42001031101 42001031101 311.01
2 42 013 100400 1400000US42013100400 42013100400 1004
3 42 013 100500 1400000US42013100500 42013100500 1005
4 42 013 100800 1400000US42013100800 42013100800 1008
5 42 013 101900 1400000US42013101900 42013101900 1019
6 42 011 011200 1400000US42011011200 42011011200 112
7 42 011 000200 1400000US42011000200 42011000200 2
8 42 011 011500 1400000US42011011500 42011011500 115
9 42 011 000600 1400000US42011000600 42011000600 6
10 42 011 001900 1400000US42011001900 42011001900 19
NAMELSAD STUSPS NAMELSADCO STATE_NAME LSAD ALAND AWATER
1 Census Tract 311.01 PA Adams County Pennsylvania CT 3043185 0
2 Census Tract 1004 PA Blair County Pennsylvania CT 993724 0
3 Census Tract 1005 PA Blair County Pennsylvania CT 1130204 0
4 Census Tract 1008 PA Blair County Pennsylvania CT 996553 0
5 Census Tract 1019 PA Blair County Pennsylvania CT 573726 0
6 Census Tract 112 PA Berks County Pennsylvania CT 1539365 9308
7 Census Tract 2 PA Berks County Pennsylvania CT 1949529 159015
8 Census Tract 115 PA Berks County Pennsylvania CT 1978380 12469
9 Census Tract 6 PA Berks County Pennsylvania CT 1460473 0
10 Census Tract 19 PA Berks County Pennsylvania CT 182420 0
geometry
1 MULTIPOLYGON (((-77.03108 3...
2 MULTIPOLYGON (((-78.42478 4...
3 MULTIPOLYGON (((-78.41661 4...
4 MULTIPOLYGON (((-78.41067 4...
5 MULTIPOLYGON (((-78.40836 4...
6 MULTIPOLYGON (((-75.95433 4...
7 MULTIPOLYGON (((-75.96071 4...
8 MULTIPOLYGON (((-75.99913 4...
9 MULTIPOLYGON (((-75.91528 4...
10 MULTIPOLYGON (((-75.91819 4...
hospitalsSimple feature collection with 223 features and 11 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: -80.49621 ymin: 39.75163 xmax: -74.86704 ymax: 42.13403
Geodetic CRS: WGS 84
First 10 features:
CHIEF_EXEC CHIEF_EX_1
1 Peter J Adamo President
2 Autumn DeShields Chief Executive Officer
3 Shawn Parekh Chief Executive Officer
4 DIANE HRITZ Chief Executive Officer
5 Tim Harclerode Chief Executive Officer
6 Richard McLaughlin MD MBA Chief Executive Officer
7 Laura Murnyack Interim CEO
8 Adam Beck Chief Executive Officer
9 Pamela Keen Chief Executive Officer
10 Mark Papalia President/CEO
FACILITY_U LONGITUDE COUNTY
1 https://www.phhealthcare.org -79.91131 Washington
2 https://www.malvernbh.com -75.17005 Philadelphia
3 https://roxboroughmemorial.com -75.20963 Philadelphia
4 https://www.ashospital.net -80.27907 Washington
5 https://www.conemaugh.org -79.02513 Somerset
6 https://towerhealth.org -75.61213 Montgomery
7 https://bucktailmedicalcenter.org -77.73649 Clinton
8 https://www.selectspecialtyhospitals.com -76.88013 Dauphin
9 https://www.childrenshomepgh.org -79.93736 Allegheny
10 https://www.kanecommunityhospital.com -78.81705 McKean
FACILITY_N
1 Penn Highlands Mon Valley
2 MALVERN BEHAVIORAL HEALTH
3 Roxborough Memorial Hospital
4 ADVANCED SURGICAL HOSPITAL
5 DLP Conemaugh Meyersdale Medical Center
6 Pottstown Hospital, LLC
7 Bucktail medical Center
8 SELECT SPECIALTY HOSPITAL CENTRAL PENNSYLVANIA HARRISBURG
9 The Children's Home of Pittsburgh
10 University of Pittsburgh Medical Center Kane
STREET CITY_OR_BO LATITUDE TELEPHONE_ ZIP_CODE
1 1163 Country Club Road Monongahela 40.18193 724-258-1000 15063
2 1930 South Broad Street Unit 4 Philadelphia 39.92619 610-480-8919 19145
3 5800 Ridge Avenue Philadelphia 40.02869 215-483-9900 19128
4 100 TRICH DRIVE\nSUITE 1 WASHINGTON 40.15655 7248840710 15301
5 200 Hospital Drive Meyersdale 39.80913 814-634-5911 15552
6 1600 East High Street Pottstown 40.24273 6103277000 19464
7 1001 Pine Street Renovo 41.32789 570-923-1000 17764
8 111 South Front Street Harrisburg 40.25841 717-724-6604 17110
9 5324 Penn Avenue Pittsburgh 40.46424 412-441-4884 15224
10 4372 US Route 6 Kane 41.67188 8148378585 16735
geometry
1 POINT (-79.91131 40.18193)
2 POINT (-75.17005 39.9262)
3 POINT (-75.20963 40.02869)
4 POINT (-80.27907 40.15655)
5 POINT (-79.02513 39.80913)
6 POINT (-75.61213 40.24273)
7 POINT (-77.73649 41.32789)
8 POINT (-76.88013 40.25842)
9 POINT (-79.93736 40.46424)
10 POINT (-78.81705 41.67188)
st_crs(pa_counties)Coordinate Reference System:
User input: WGS 84 / Pseudo-Mercator
wkt:
PROJCRS["WGS 84 / Pseudo-Mercator",
BASEGEOGCRS["WGS 84",
ENSEMBLE["World Geodetic System 1984 ensemble",
MEMBER["World Geodetic System 1984 (Transit)"],
MEMBER["World Geodetic System 1984 (G730)"],
MEMBER["World Geodetic System 1984 (G873)"],
MEMBER["World Geodetic System 1984 (G1150)"],
MEMBER["World Geodetic System 1984 (G1674)"],
MEMBER["World Geodetic System 1984 (G1762)"],
MEMBER["World Geodetic System 1984 (G2139)"],
MEMBER["World Geodetic System 1984 (G2296)"],
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ENSEMBLEACCURACY[2.0]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]],
CONVERSION["Popular Visualisation Pseudo-Mercator",
METHOD["Popular Visualisation Pseudo Mercator",
ID["EPSG",1024]],
PARAMETER["Latitude of natural origin",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["False easting",0,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",0,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["easting (X)",east,
ORDER[1],
LENGTHUNIT["metre",1]],
AXIS["northing (Y)",north,
ORDER[2],
LENGTHUNIT["metre",1]],
USAGE[
SCOPE["Web mapping and visualisation."],
AREA["World between 85.06°S and 85.06°N."],
BBOX[-85.06,-180,85.06,180]],
ID["EPSG",3857]]
st_crs(pa_tracts)Coordinate Reference System:
User input: NAD83
wkt:
GEOGCRS["NAD83",
DATUM["North American Datum 1983",
ELLIPSOID["GRS 1980",6378137,298.257222101,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["latitude",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["longitude",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4269]]
st_crs(hospitals)Coordinate Reference System:
User input: WGS 84
wkt:
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic latitude (Lat)",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["geodetic longitude (Lon)",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]]
pa_tracts <- st_transform(pa_tracts, st_crs(pa_counties))