I found life expectancy at birth data for “health regions” in Canada for 2015-2017 and in “census tracts” in the USA for 2010-2015.

Here is a map of these two countries, excluding areas with a life expectancy at birth lower than 0.

Data sources and shapefiles:

Libraries

The usual data wrangling libraries for spatial data (tidyverse, sf), mapped using mapview and leaflet.

tigrisis used to download USA census tract shapefiles for the year 2015.

I tried ggmap for static map, but for some reason my polygons were offset to the North of the tiles.

test avec mapviewOptions(platform = “mapdeck”)

Map of both countries excluding areas with life expectancy at birth below 80. Maine and Wisonsin are excluded because data is not available.

both <- list(
  usa_mortality_with_boundary %>%
    select(ID = tract_id ,
           NAME = NAME,
           e_0 = e_0
    )%>%
    st_transform(crs=4326)
  ,
  canada_mortality_with_boundary %>%
    select(ID = HR_UID,
           NAME = geo2,
           e_0 = value) %>%
    st_transform(crs=4326)
)


# map both!
both_mortality_with_boundary <-sf::st_as_sf(
  data.table::rbindlist(both))


#https://twitter.com/TimSalabim3/status/1206673522053066753
#mapviewOptions(platform = "leaflet")
mymapview <- both_mortality_with_boundary %>%
  filter(e_0 > 80) %>%
  mapview::mapview(zcol = "e_0",
                   layer.name = "Life expectancy at birth <br> 
                   when above 80 <br>
                   Canada 2015-2017 <br>
                   USA 2010-2015")  
mymapview@map %>%
  addPolygons(data= usa_states %>% filter(STUSPS %in% c("ME","WI")),
              color = "gray60", fillColor = "gray60")