bucky.viz.map
¶
Bucky Mapping Tools.
Creates maps at the ADM0, ADM1, or ADM2 level.
Module Contents¶
Functions¶
|
Given a pandas.DataFrame of simulation data, this method returns dates based on the requested frequency. |
|
Read requested simulation data. |
|
Given admin2 shape data, finds matching admin1 shape data in order to get the admin1 outline. |
|
Create adm1 maps. |
|
Create a map for each date and column. |
Attributes¶
- bucky.viz.map.args¶
- bucky.viz.map.default_cmap = Reds¶
- bucky.viz.map.default_plot_cols = ['daily_reported_cases', 'daily_deaths']¶
- 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 datafrequency (
{"weekly", "daily", "monthly"}
) – Frequency of selected dates
- Returns
date_list – List of dates
- Return type
- 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 dataadm_level (
{"adm0", "adm1"}
) – Admin level of requested map
- Returns
df – Requested preprocessed simulation data
- Return type
- 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
adm2_data (
geopandas.GeoDataFrame
) – Admin2-level shape dataadm1_data (
geopandas.GeoDataFrame
) – Admin1-level shape data
- Returns
outline_df – Admin1-level shape data that match values in admin2
- Return type
- 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 leveladm1_shape_df (
geopandas.GeoDataFrame
) – Shapefile information at the admin1 leveldf (
pandas.DataFrame
) – Simulation data to plotlookup_df (
pandas.DataFrame
) – Dataframe containing mapping between admin levelsadm1_list (
list
ofstr
, orNone
) – List of explicit admin1 names to create names for. If None, a map is made for each unique admin1 in the lookup tableoutput_dir (
str
) – Directory to place created mapscolormap (
str
, default"Reds"
) – Colormap to use; must be a valid Matplotlib colormapadd_outline (
bool
, defaultFalse
) – 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 leveldf (
pandas.DataFrame
) – Simulation data to plotadm_key (
str
) – Admin level keyoutput_dir (
str
) – Directory to place created mapslog_scale (
bool
) – If true, uses log scalingcolormap (
str
, default"Reds"
) – Colormap to use; must be a valid Matplotlib colormapoutline_df (
geopandas.GeoDataFrame
, orNone
) – Shapefile for outline