Example Visualizations using CyberGIS-Vis

Documentations and Demos about CyberGIS-Vis are available at: https://github.com/su-gis/CyberGIS-Vis

Adaptive Choropleth Mapper with Multiple Line Chart (MLC): Temporal Patterns of Covid-19 Crude Rate and Death Rate in US Counties

Setup environment

In [1]:
import pandas as pd
import geopandas as gpd
from Adaptive_Choropleth_Mapper import CLC, MLC, Initial_Layers

Set input Data

  1. Load U.S. counties from the Shapefile. Note: New York is an exception, represented by New York City with the city ID 777777, instead of county names and IDs.
  • Read the Shapefile "County_NY_TIMES.shp" into a GeoDataFrame
  • The Shapefile is located in the "shp/US/" directory
  • The 'geoid' column is explicitly set to be read as a string (str)
  • The first column in both the attribute file and the shapefile must be named 'geoid,' as it serves as the key for joining the shapefile with the attribute data.
  • The second column should contain the names of the corresponding regions, which will be directly displayed on the resulting map.
In [2]:
shapefile = gpd.read_file("shp/US/County_NY_TIMES.shp", dtype={'geoid': str})
shapefile
Out[2]:
geoid name Shape_Leng Shape_Area geometry
0 10001 Kent,DE 2.029682 0.215240 POLYGON ((-75.74776 39.14334, -75.75600 39.246...
1 10003 New Castle,DE 1.798779 0.134081 POLYGON ((-75.78860 39.72220, -75.77379 39.722...
2 10005 Sussex,DE 2.369084 0.320841 POLYGON ((-75.70157 38.56074, -75.70744 38.635...
3 1001 Autauga,AL 1.994948 0.150242 POLYGON ((-86.41312 32.70739, -86.41279 32.625...
4 1003 Baldwin,AL 3.977560 0.494110 POLYGON ((-87.59883 30.99745, -87.59650 30.987...
... ... ... ... ... ...
3212 9007 Middlesex,CT 1.878172 0.122471 POLYGON ((-72.75218 41.57889, -72.75294 41.592...
3213 9009 New Haven,CT 2.629868 0.240237 POLYGON ((-73.31047 41.46881, -73.32091 41.477...
3214 9011 New London,CT 2.390277 0.215441 POLYGON ((-72.46673 41.58390, -72.41723 41.590...
3215 9013 Tolland,CT 1.812081 0.117074 POLYGON ((-72.13572 42.03025, -72.10217 42.028...
3216 9015 Windham,CT 1.754612 0.146376 POLYGON ((-71.78970 41.72456, -71.78725 41.656...

3217 rows × 5 columns

  1. Load the attribute data that will be used for visualization. Data Source: "The New York Times. (2021). Coronavirus (Covid-19) Data in the United States. Retrieved [08/01/2024], from https://github.com/nytimes/covid-19-data."
  • Read the CSV file "Covid_Rate_Mobility_US_2020_2021_weekly.csv" into a DataFrame
  • The CSV file is located in the "attributes/" directory
  • The 'geoid' column is explicitly set to be read as a string (str)
  • The first column in both the attribute file and the shapefile must be named 'geoid,' as it serves as the key for joining the shapefile with the attribute data.
  • The second column header must be named 'period' and should contain time-related values, such as days, months, or years, formatted as YYYY, MM-DD, or MM-DD-YYYY."
In [3]:
attributes = pd.read_csv("attributes/Covid_Rate_Mobility_US_2020_2021_weekly.csv", dtype={'geoid': str} )
attributes
Out[3]:
geoid period confirmed_rate death_rate confirmed_rate_total death_rate_total visitor_flows_to_selected_area visitor_flows_from_selected_area pop_flows_to_selected_area pop_flows_from_selected_area confirmed_cases_total death_total cases death pop
0 25021 2020-03-02 76.34 0.000000 76.34 0.000000 225932.0 222941.0 4296827.0 4489797.0 1 0 1 0 131
1 17031 2020-03-02 0.27 0.000000 1.88 0.000000 2410769.0 2203579.0 34150598.0 31518502.0 7 0 1 0 37172
2 6095 2020-03-02 0.12 0.000000 2.97 0.000000 155015.0 176145.0 2935064.0 3281805.0 24 0 1 0 80680
3 6075 2020-03-02 0.00 0.000000 3.45 0.000000 291306.0 221035.0 5711711.0 4196901.0 6 0 0 0 17376
4 12057 2020-03-02 7.16 0.000000 14.33 0.000000 943468.0 855974.0 10914786.0 9880641.0 2 0 1 0 1396
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
276123 42109 2021-11-22 261.53 0.000000 57660.29 1214.848144 27845.0 15230.0 415693.0 228453.0 20504 432 93 0 3556
276124 42107 2021-11-22 134.07 2.180000 22966.91 532.710791 40167.0 52320.0 568134.0 733340.0 84114 1951 491 8 36624
276125 27139 2021-11-22 75.85 0.622421 8641.97 61.708636 53778.0 75885.0 725802.0 979598.0 97191 694 853 7 112464
276126 42121 2021-11-22 1559.36 35.210000 148385.31 3143.863179 14101.0 15193.0 196044.0 202678.0 29499 625 310 7 1988
276127 9015 2021-11-22 25.40 0.120000 6932.50 109.875203 32688.0 43879.0 502565.0 641831.0 56217 891 206 1 81092

276128 rows × 15 columns

</br></br>

Set the parameters to create visualizations using Multiple Linked Charts (MLC).

The interface will include two choropleth maps, a chart displaying the top or bottom values of your selected variable, such as COVID-19 confirmed rates, within the geographic regions of your map, and multiple linked charts (MLC). The MLC feature allows users to click on any county to explore spatiotemporal patterns of selected variables, such as COVID-19 confirmed or death rates, across multiple time series charts.

     Your result visualization would be similar to the image below.</br>     

  • Specifying the map center and zoom levels is optional in MLC([latitude, longitude], zoom level). When MLC() is called without these parameters, the map center and zoom levels are automatically adjusted.
In [4]:
MLC([38, -97], 4)

</br></br>

Set the parameters to create visualizations using Comparison Line Chart (CLC).

Configure the parameters to visualize your COVID-19 datasets using the Comparison Line Chart (CLC). The interface will include two choropleth maps, a chart displaying the top or bottom values of your selected variable, such as COVID-19 confirmed rates, within the geographic regions of your map, and the Comparison Line Chart (CLC). The CLC feature allows users to click on any county on the two choropleth maps to compare spatiotemporal patterns of selected variables, such as COVID-19 confirmed or death rates, in a single interactive line chart.

     Your result visualization would be similar to the image below.</br>     

  • Specifying the map center and zoom levels is optional in CLC([latitude, longitude], zoom level). When CLC() is called without these parameters, the map center and zoom levels are automatically adjusted.
In [5]:
CLC([38, -97], 4)