R Week 07 Assignment

Author

Zirui Zheng

Published

February 22, 2025

Explanation of the template

R Spatial Lab Assignment # 1

task 1: Import necessary libraries and data path

task 2: Read the NYC postal areas in Shapefiles

Reading layer `ZIP_CODE_040114' from data source 
  `/Users/ziruizheng/Desktop/College Class/Now/Data Analysis & Viz/2025_Spring_week 7-10/Section_07/R-Spatial_I_Lab/ZIP_CODE_040114/ZIP_CODE_040114.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 263 features and 12 fields
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 913129 ymin: 120020.9 xmax: 1067494 ymax: 272710.9
Projected CRS: NAD83 / New York Long Island (ftUS)
Rows: 12
Columns: 5
$ ZIPCODE    <chr> "11005", "11109", "10006", "10004", "10004", "10004", "1000…
$ POPULATION <dbl> 3533, 2752, 3011, 2187, 2187, 2187, 2187, 147, 147, 3170, 2…
$ SHAPE_AREA <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
$ SHAPE_LEN  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
$ geometry   <POLYGON [US_survey_foot]> POLYGON ((1063782 216277.1,..., POLYGON ((995983.3 211173, …

task 3: Read and process the NYS health facilities

 [1] "Facility.ID"                  "Facility.Name"               
 [3] "Short.Description"            "Description"                 
 [5] "Facility.Open.Date"           "Facility.Address.1"          
 [7] "Facility.Address.2"           "Facility.City"               
 [9] "Facility.State"               "Facility.Zip.Code"           
[11] "Facility.Phone.Number"        "Facility.Fax.Number"         
[13] "Facility.Website"             "Facility.County.Code"        
[15] "Facility.County"              "Regional.Office.ID"          
[17] "Regional.Office"              "Main.Site.Name"              
[19] "Main.Site.Facility.ID"        "Operating.Certificate.Number"
[21] "Operator.Name"                "Operator.Address.1"          
[23] "Operator.Address.2"           "Operator.City"               
[25] "Operator.State"               "Operator.Zip.Code"           
[27] "Cooperator.Name"              "Cooperator.Address"          
[29] "Cooperator.Address.2"         "Cooperator.City"             
[31] "Cooperator.State"             "Cooperator.Zip.Code"         
[33] "Ownership.Type"               "Facility.Latitude"           
[35] "Facility.Longitude"           "Facility.Location"           
Rows: 620
Columns: 3
$ Facility.Name  <chr> "Charles T Sitrin Health Care Center Inc", "East Side N…
$ Ownership.Type <chr> "Not for Profit Corporation", "Business Corporation", "…
$ geometry       <POINT> POINT (-75.22883 43.05497), POINT (-78.12867 42.73898…
[1] "Facility.Name"  "Ownership.Type" "geometry"      

task 4: Read and process the NYS retail food stores

 [1] "ï..County"          "License.Number"     "Operation.Type"    
 [4] "Establishment.Type" "Entity.Name"        "DBA.Name"          
 [7] "Street.Number"      "Street.Name"        "Address.Line.2"    
[10] "Address.Line.3"     "City"               "State"             
[13] "Zip.Code"           "Square.Footage"     "Location"          
[16] "Coords"             "Y"                  "X"                 
Rows: 287
Columns: 3
$ Entity.Name    <chr> "ALL NATURAL CO INC               ", "DUANE READE ETAL …
$ Square.Footage <dbl> 7250, 7300, 7500, 7500, 7500, 7500, 7500, 7500, 7500, 7…
$ geometry       <POINT [°]> POINT (-73.9843 40.72898), POINT (-73.98229 40.76…

task 5.1: Create MapView() for the ZIP CODE sf



Notice:

Here is a full graph of zip code area above. I reduced the size of
the spatial file from 200 to 12, because mapview() renders the zip
code areas in polygon shapes instead of drawing dotted points, which
requires significant GPU by RPubs. Therefore the full graph cannot be
generated by RPubs, I attached a PNG version of this full graph
visualization for your reference :)

task 5.2: Create MapView() for the health facility sf

task 5.3: Create MapView() for the HEALTH FACILITY sf



Notice:

Here for the same reason of large file size issue, I have reduced the
size of retail_food spatial file by filtering out small
square.footage. Down below is a PNG version of this complete data
graph visualization for your reference :)

task 6: Save 3 objects in a RData

[1] "/Users/ziruizheng/Desktop/College Class/Now/Data Analysis & Viz/2025_Spring_week 7-10/Section_07/R-Spatial_I_Lab"