Home > Enterprise >  How can I create a heatmap on a map using only zipcodes
How can I create a heatmap on a map using only zipcodes

Time:12-22

I have the dataframe below and I wonder if I can draw a heatmap on a Chicago map using only the zipcodes. Count will be used as numeric value.

structure(list(Zip = structure(c(15L, 19L, 25L, 27L, 30L, 30L, 
41L), .Label = c("60411", "60415", "60462", "60607", "60608", 
"60609", "60610", "60612", "60613", "60614", "60615", "60616", 
"60617", "60618", "60619", "60620", "60621", "60622", "60623", 
"60624", "60625", "60626", "60628", "60629", "60630", "60631", 
"60632", "60633", "60634", "60636", "60637", "60638", "60639", 
"60640", "60641", "60642", "60643", "60644", "60645", "60646", 
"60647", "60649", "60651", "60652", "60653", "60655", "60656", 
"60657", "60659", "60660", "60707"), class = "factor"), Count = c(2L, 
2L, 2L, 2L, 2L, 2L, 2L)), class = c("grouped_df", "tbl_df", "tbl", 
"data.frame"), row.names = c(NA, -7L), groups = structure(list(
    Zip = structure(c(15L, 19L, 25L, 27L, 30L, 41L), .Label = c("60411", 
    "60415", "60462", "60607", "60608", "60609", "60610", "60612", 
    "60613", "60614", "60615", "60616", "60617", "60618", "60619", 
    "60620", "60621", "60622", "60623", "60624", "60625", "60626", 
    "60628", "60629", "60630", "60631", "60632", "60633", "60634", 
    "60636", "60637", "60638", "60639", "60640", "60641", "60642", 
    "60643", "60644", "60645", "60646", "60647", "60649", "60651", 
    "60652", "60653", "60655", "60656", "60657", "60659", "60660", 
    "60707"), class = "factor"), .rows = structure(list(1L, 2L,3L, 4L, 5:6, 7L), ptype = integer(0), class = c("vctrs_list_of", 
    "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -6L), .drop = TRUE)) 

CodePudding user response:

You need a mapping between zip codes and geospatial boundaries. Here is an option:

  1. enter image description here

  • Related