bucky.viz.map

Bucky Mapping Tools.

Creates maps at the ADM0, ADM1, or ADM2 level.

Module Contents

Functions

get_dates(df, frequency='weekly')

Given a pandas.DataFrame of simulation data, this method returns dates based on the requested frequency.

get_map_data(data_dir, adm_level)

Read requested simulation data.

get_state_outline(adm2_data, adm1_data)

Given admin2 shape data, finds matching admin1 shape data in order to get the admin1 outline.

make_adm1_maps(adm2_shape_df, adm1_shape_df, df, lookup_df, dates, cols, adm1_list, output_dir, log_scale=True, colormap='Reds', add_outline=False)

Create adm1 maps.

make_map(shape_df, df, dates, adm_key, cols, output_dir, title_prefix=None, log_scale=True, colormap='Reds', outline_df=None)

Create a map for each date and column.

bucky.viz.map.args[source]
bucky.viz.map.default_cmap = Reds[source]
bucky.viz.map.default_plot_cols = ['daily_reported_cases', 'daily_deaths'][source]
bucky.viz.map.parser[source]
bucky.viz.map.get_dates(df, frequency='weekly')[source]

Given a pandas.DataFrame of simulation data, this method returns dates based on the requested frequency.

Parameters
  • df (pandas.DataFrame) – Dataframe of simulation data

  • frequency ({"weekly", "daily", "monthly"}) – Frequency of selected dates

Returns

date_list – List of dates

Return type

list of str

bucky.viz.map.get_map_data(data_dir, adm_level)[source]

Read requested simulation data.

Maps are created using one level down from the requested map level. For example, a national map is created using state-level data.

Parameters
  • data_dir (str) – Location of preprocessed simulation data

  • adm_level ({"adm0", "adm1"}) – Admin level of requested map

Returns

df – Requested preprocessed simulation data

Return type

pandas.DataFrame

bucky.viz.map.get_state_outline(adm2_data, adm1_data)[source]

Given admin2 shape data, finds matching admin1 shape data in order to get the admin1 outline.

Parameters
Returns

outline_df – Admin1-level shape data that match values in admin2

Return type

geopandas.GeoDataFrame

bucky.viz.map.make_adm1_maps(adm2_shape_df, adm1_shape_df, df, lookup_df, dates, cols, adm1_list, output_dir, log_scale=True, colormap='Reds', add_outline=False)[source]

Create adm1 maps.

Parameters
  • adm2_shape_df (geopandas.GeoDataFrame) – Shapefile information at the admin2 level

  • adm1_shape_df (geopandas.GeoDataFrame) – Shapefile information at the admin1 level

  • df (pandas.DataFrame) – Simulation data to plot

  • lookup_df (pandas.DataFrame) – Dataframe containing mapping between admin levels

  • dates (list of str) – List of dates to make maps for

  • cols (list of str) – List of columns to make maps for

  • adm1_list (list of str, or None) – List of explicit admin1 names to create names for. If None, a map is made for each unique admin1 in the lookup table

  • output_dir (str) – Directory to place created maps

  • log_scale (bool, default True) – If true, uses log scaling

  • colormap (str, default "Reds") – Colormap to use; must be a valid Matplotlib colormap

  • add_outline (bool, default False) – Add a thicker outline to the map

bucky.viz.map.make_map(shape_df, df, dates, adm_key, cols, output_dir, title_prefix=None, log_scale=True, colormap='Reds', outline_df=None)[source]

Create a map for each date and column.

Parameters
  • shape_df (geopandas.GeoDataFrame) – Shapefile information at the required admin level

  • df (pandas.DataFrame) – Simulation data to plot

  • dates (list of str) – List of dates to make maps for

  • adm_key (str) – Admin level key

  • cols (list of str) – List of columns to make maps for

  • output_dir (str) – Directory to place created maps

  • title_prefix (str, or None) – String to add to map prefix

  • log_scale (bool) – If true, uses log scaling

  • colormap (str, default "Reds") – Colormap to use; must be a valid Matplotlib colormap

  • outline_df (geopandas.GeoDataFrame, or None) – Shapefile for outline