import pandas as pd
import geopandas as gpd
from Adaptive_Choropleth_Mapper import Adaptive_Choropleth_Mapper_viz, Adaptive_Choropleth_Mapper_log
input_attributes = pd.read_csv("attributes/Los_Angeles_1980_1990_2000_2010.csv", dtype={'geoid':str})
input_attributes = input_attributes.rename(columns={'geoid': 'geoid', 'year': 'period'})
input_attributes
shapefile = gpd.read_file("shp/Los_Angeles_tract/Los_Angeles_2.shp")
shapefile = shapefile.rename(columns={'tractID': 'geoid', 'tract_key': 'name'})
shapefile
param_Stacked = {
'title': "Adaptive Choropleth Mapper with Stacked Chart",
'filename_suffix': "LA",
'inputCSV': input_attributes,
'shapefile': shapefile,
'periods': [1980, 1990, 2000, 2010],
'shortLabelCSV': "attributes/LTDB_ShortLabel.csv",
'variables': [ # Enter variable names of the column you entered above.
"p_nonhisp_white_persons",
"p_nonhisp_black_persons",
"p_hispanic_persons",
"p_asian_persons",
"p_employed_manufacturing",
"p_poverty_rate",
"p_foreign_born_pop",
"p_persons_under_18",
"p_persons_over_60",
"p_edu_college_greater",
"p_unemployment_rate",
"p_employed_professional",
"p_vacant_housing_units",
"p_owner_occupied_units",
"p_housing_units_multiunit_structures",
"median_home_value",
"p_structures_30_old",
"p_household_recent_move",
],
'NumOfMaps': 4,
'SortLayers': "temporal", # Enter “compare” or “temporal”. compare mode is for comparing variables at a specific point of time.
# temporal mode is for displaying spatiotemporal patterns of the same variable using multiple maps.
'InitialLayers':["1980_% nonhisp white persons", "1990_% nonhisp white persons", "2000_% nonhisp white persons", "2010_% nonhisp white persons"],
'Map_width':"350px",
'Map_height':"350px",
'Stacked_Chart': False, #Comment out if you do not want to visualize this chart
}
Adaptive_Choropleth_Mapper_viz(param_Stacked)
Adaptive_Choropleth_Mapper_log(param_Stacked)
param_Stacked = {
'title': "Adaptive Choropleth Mapper with Stacked Chart",
'filename_suffix': "LA_Stacked",
'inputCSV': input_attributes,
'shapefile': shapefile,
'periods': [1980, 1990, 2000, 2010],
'NumOfMaps': 4,
'shortLabelCSV': "attributes/LTDB_ShortLabel.csv",
'variables': [ # Enter variable names of the column you entered above.
"p_nonhisp_white_persons",
"p_nonhisp_black_persons",
"p_hispanic_persons",
"p_asian_persons",
"p_employed_manufacturing",
"p_poverty_rate",
"p_foreign_born_pop",
"p_persons_under_18",
"p_persons_over_60",
"p_edu_college_greater",
"p_unemployment_rate",
"p_employed_professional",
"p_vacant_housing_units",
"p_owner_occupied_units",
"p_housing_units_multiunit_structures",
"median_home_value",
"p_structures_30_old",
"p_household_recent_move",
],
'NumOfMaps': 4,
'SortLayers': "temporal", # Enter “compare” or “temporal”. compare mode is for comparing variables at a specific point of time.
# temporal mode is for displaying spatiotemporal patterns of the same variable using multiple maps.
'InitialLayers':["1980_% nonhisp white persons", "1990_% nonhisp white persons", "2000_% nonhisp white persons", "2010_% nonhisp white persons"],
'Map_width':"350px",
'Map_height':"350px",
'Stacked_Chart': True, #Comment out if you do not want to visualize this chart
}
Adaptive_Choropleth_Mapper_viz(param_Stacked)
Adaptive_Choropleth_Mapper_log(param_Stacked)
param_bar = {
'title': "Adaptive Choropleth Mapper with Top 10 Bar Chart",
'filename_suffix': "LA_bar",
'inputCSV': input_attributes,
'shapefile': shapefile,
'periods': [1980, 1990, 2000, 2010],
'NumOfMaps': 3,
'shortLabelCSV': "attributes/LTDB_ShortLabel.csv",
'variables': [ #enter variable names of the column you entered above.
"p_other_language",
"p_female_headed_families",
"per_capita_income",
],
'Top10_Chart': True, #Comment out if you do not want to visualize this chart
}
Adaptive_Choropleth_Mapper_viz(param_bar)
Adaptive_Choropleth_Mapper_log(param_bar)
param_Scatter = {
'title': "Adaptive Choropleth Mapper with Scatter Plot",
'filename_suffix': "LA_Scatter",
'inputCSV': input_attributes,
'shapefile': shapefile,
'periods': [2010],
'shortLabelCSV': "attributes/LTDB_ShortLabel.csv",
'variables': [ #enter variable names of the column you entered above.
"p_nonhisp_white_persons",
"p_nonhisp_black_persons",
"p_hispanic_persons",
"p_asian_persons",
"p_foreign_born_pop",
"p_edu_college_greater",
"p_unemployment_rate",
"p_employed_manufacturing",
"p_poverty_rate",
"p_vacant_housing_units",
"p_owner_occupied_units",
"p_housing_units_multiunit_structures",
"median_home_value",
"p_structures_30_old",
"p_household_recent_move",
"p_persons_under_18",
"p_persons_over_60",
],
'InitialLayers':["2010_% edu college greater", "2010_% employed manufacturing" ],
'Map_width':"470px",
'Map_height':"450px",
'Scatter_Plot': True,
}
Adaptive_Choropleth_Mapper_viz(param_Scatter)
Adaptive_Choropleth_Mapper_log(param_Scatter)
param_Correlogram = {
'title': "Adaptive Choropleth Mapper with Correlogram",
'filename_suffix': "LA_Correlogram",
'inputCSV': input_attributes,
'shapefile': shapefile,
'NumOfMaps':6,
'periods': [2010],
'shortLabelCSV': "attributes/LTDB_ShortLabel.csv",
'variables': [ #enter variable names of the column you entered above.
"p_nonhisp_white_persons",
"p_nonhisp_black_persons",
"p_hispanic_persons",
"p_asian_persons",
"p_foreign_born_pop",
"p_edu_college_greater",
"p_unemployment_rate",
"p_employed_manufacturing",
"p_poverty_rate",
"p_vacant_housing_units",
"p_owner_occupied_units",
"p_housing_units_multiunit_structures",
"median_home_value",
"p_structures_30_old",
"p_household_recent_move",
"p_persons_under_18",
"p_persons_over_60",
],
'Map_width':"350px",
'Map_height':"350px",
'Correlogram': True,
}
Adaptive_Choropleth_Mapper_viz(param_Correlogram)
Adaptive_Choropleth_Mapper_log(param_Correlogram)
param_PCP = {
'title': "Adaptive Choropleth Mapper with Paralle Coordinate Plot",
'filename_suffix': "Census_PCP", # max 30 character
'inputCSV': input_attributes,
'shapefile': shapefile,
'periods': [2010],
'variables': [ #enter variable names of the column you entered above.
"p_nonhisp_white_persons",
"p_nonhisp_black_persons",
"p_hispanic_persons",
"p_asian_persons",
"p_employed_manufacturing",
"p_poverty_rate",
"p_foreign_born_pop",
"p_persons_under_18",
"p_persons_over_60",
"p_edu_college_greater",
"p_unemployment_rate",
"p_employed_professional",
"p_vacant_housing_units",
"p_owner_occupied_units",
"p_housing_units_multiunit_structures",
"median_home_value",
"p_structures_30_old",
"p_household_recent_move",
],
'shortLabelCSV': "attributes/LTDB_ShortLabel.csv",
'NumOfMaps':4,
'Map_width':"350px",
'Map_height':"350px",
'Top10_Chart': True,
'Parallel_Coordinates_Plot': True,
'NumOfPCP':4,
'InitialVariablePCP': ["2010_% white (non-Hispanic)", "2010_% black (non-Hispanic)", "2010_% Hispanic", "2010_% Asian & PI race", "2010_% professional employees", "2010_% manufacturing employees", "2010_% in poverty", "2010_% foreign born", "2010_% 17 and under (total)", "2010_% 60 and older"]
}
Adaptive_Choropleth_Mapper_viz(param_PCP)
Adaptive_Choropleth_Mapper_log(param_PCP)
Covid_Visits = pd.read_csv("attributes/Covid_Visits.csv", dtype={'geoid':str})
Covid_Visits = Covid_Visits.rename(columns={'geoid': 'geoid'})
Covid_Visits
shapefile_MSA = gpd.read_file("shp/MSA_country/MSA_US.shp", dtype={'GEOID':str})
shapefile_MSA = shapefile_MSA.rename(columns={'GEOID': 'geoid', 'NAME_1':'name'})
shapefile_MSA
param_MLC_COVID = {
'title': "Covid-19 Risk Assessment using Twitter, Metropolitan Statistical Areas, USA",
'Subject': "Temporal Patterns of COVID-19 Risk Factors",
'filename_suffix': "Mobility_MLC", # max 30 character
'inputCSV': Covid_Visits,
'shapefile': shapefile_MSA,
'periods': "All",
'variables': [ #enter variable names of the column you entered above.
"Confirmed Rate",
"Death Rate",
"The Number of Visits from Outside to Inside of the selected MSA"
],
'NumOfMaps':2,
'InitialLayers':["2020-03-15_Confirmed Rate" , "2020-12-27_Confirmed Rate"],
'Initial_map_center':[37, -97],
'Initial_map_zoom_level':4,
'Map_width':"650px",
'Map_height':"400px",
'Top10_Chart': True,
'Multiple_Line_Chart': True,
'NumOfMLC':3,
'titlesOfMLC':["1. COVID-19 Confirmed Cases (/100k pop)", "2. COVID-19 Death Cases (/100k pop)", "3. The Number of Visits from Outside to Inside of the selected MSA"],
'DefaultRegion_MLC':"35620"
}
Adaptive_Choropleth_Mapper_viz(param_MLC_COVID)
Adaptive_Choropleth_Mapper_log(param_MLC_COVID)
param_CLC_COVID = {
'title': "Comparison of COVID-19 Confirmed Rate between Metropolitan Statistical Areas, USA",
'Subject': "Temporal Patterns of COVID-19 Confirmed Rate",
'filename_suffix': "Mobility_CLC", # max 30 character
'inputCSV': Covid_Visits,
'shapefile': shapefile_MSA,
'periods': "All",
'variables': [ #enter variable names of the column you entered above.
"Confirmed Rate"
],
'NumOfMaps':2,
'InitialLayers':["2020-04-19_Confirmed Rate" , "2020-11-01_Confirmed Rate"],
'Initial_map_center':[37, -97],
'Initial_map_zoom_level':4,
'Map_width':"650px",
'Map_height':"400px",
'Top10_Chart': True,
'Comparision_Chart': True,
'NumOfCLC': 46,
'DefaultRegion_CLC': ["35620", "16980"]
}
Adaptive_Choropleth_Mapper_viz(param_CLC_COVID)
Adaptive_Choropleth_Mapper_log(param_CLC_COVID)
input_attributes_hiv = pd.read_csv("attributes/HIV_US_multiple_long.csv", dtype={'geoid':str})
input_attributes_hiv = input_attributes_hiv.rename(columns={'geoid': 'geoid'})
input_attributes_hiv
shapefile_us = gpd.read_file("shp/US/counties.shp")
shapefile_us
param_PCP_hiv = {
'title': "Adaptive Choropleth Mapper with Paralle Coordinate Plot",
'filename_suffix': "HIV_PCP", # max 30 character
'inputCSV': input_attributes_hiv,
'shapefile': shapefile_us,
'periods': [2012, 2013, 2014, 2015, 2016, 2017, 2018],
'variables': [ #enter variable names of the column you entered above.
"HIV",
#"Health Care Center (/100k pop)"
],
'NumOfMaps':2,
'Initial_map_center':[37, -97],
'Initial_map_zoom_level':4,
'Map_width':"650px",
'Map_height':"410px",
'Top10_Chart': True,
'Parallel_Coordinates_Plot': True,
'NumOfPCP':7,
}
Adaptive_Choropleth_Mapper_viz(param_PCP_hiv)
Adaptive_Choropleth_Mapper_log(param_PCP_hiv)
import pandas as pd
import geopandas as gpd
from Adaptive_Choropleth_Mapper import Adaptive_Choropleth_Mapper_viz, Adaptive_Choropleth_Mapper_log
# Read attributes
input_attr_PHX = pd.read_csv("attributes/Harmonized_Maricopa_Pinal_2023_harminized_in_2018_byCbg_normalized.csv", dtype={'geoid':str})
input_attr_PHX = input_attr_PHX.rename(columns={'GEOID': 'geoid'})
# add or overwrite period column
input_attr_PHX["period"] = 2023
# reorder columns to make period the second one
cols = input_attr_PHX.columns.tolist()
# move 'period' right after the first column
cols.insert(1, cols.pop(cols.index("period")))
input_attr_PHX = input_attr_PHX[cols]
# ensure it's treated as string and zero-padded to 12 digits
input_attr_PHX["geoid"] = input_attr_PHX["geoid"].astype(str).str.zfill(12)
input_attr_PHX
# Read shapefile
shapefile_PHX = gpd.read_file("shp/Phoenix/phoenix_boundary_modified.shp")
shapefile_PHX
# Create maps with Adative Choropleth Mapper
param_PHX = {
'title': "Socioeconomic Data Visualization in the Phoenix Urban Core",
'filename_suffix': "Phoenix_Core",
'inputCSV': input_attr_PHX,
'shapefile': shapefile_PHX,
'periods': [2023],
'variables': [ # Enter variable names of the column you entered above.
"Median household income",
"% below poverty",
"% Unemployed",
"% College or above",
"% manufacturing",
"% service industry",
"% structures more than 30 years old",
"% households moved <10 years ago",
"% multiunit structures",
"% owner occupied housing",
"% vacant housing",
"% > 60 years old",
"% < 18 years old",
"% white",
"% Asian",
"% Hispanic",
"% black",
"% American Indian and Alaska Native alone",
"% foreign born"
],
'NumOfMaps': 19,
'Initial_map_center':[33.55, -112.07],
'Initial_map_zoom_level':10,
'SortLayers': "compare", # Enter “compare” or “temporal”. compare mode is for comparing variables at a specific point of time.
# temporal mode is for displaying spatiotemporal patterns of the same variable using multiple maps.
#'InitialLayers':["1980_% nonhisp white persons", "1990_% nonhisp white persons", "2000_% nonhisp white persons", "2010_% nonhisp white persons"],
'Map_width':"400px",
'Map_height':"480px",
'Stacked_Chart': False, #Comment out if you do not want to visualize this chart
}
Adaptive_Choropleth_Mapper_viz(param_PHX)
input_attr_PHX.columns
import pandas as pd
import geopandas as gpd
from Adaptive_Choropleth_Mapper import Adaptive_Choropleth_Mapper_viz, Adaptive_Choropleth_Mapper_log
# Read attributes
input_attr_CHI = pd.read_csv("attributes/ACS_2018_5year__zipcode_Cook_byZipcode_normalized.csv", dtype={'geoid':str})
input_attr_CHI = input_attr_CHI.rename(columns={'GEOID': 'geoid', 'year': 'period'})
input_attr_CHI
# Read shapefile
shapefile_CHI = gpd.read_file("shp/Chicago/zipcode_Cook_County.shp", dtype={'geoid':str})
# add or overwrite period column
shapefile_CHI["name"] = shapefile_CHI['GEOID10']
shapefile_CHI = shapefile_CHI.rename(columns={'GEOID10': 'geoid'})
# Reorder columns: geoid (1st), name (2nd), geometry (3rd)
# Keep only these three, or include others if you like
shapefile_CHI = shapefile_CHI[["geoid", "name", "geometry"]]
shapefile_CHI
param_CHI = {
'title': "Socioeconomic Data Visualization in Chicago",
'filename_suffix': "Chicago_Core",
'inputCSV': input_attr_CHI,
'shapefile': shapefile_CHI,
'periods': [2018],
'variables': [ # Enter variable names of the column you entered above.
"Median monthly housing costs",
"% below poverty",
"% unemployed",
"% with 4year college degree",
"% manufacturing",
"% service industry",
"% structures more than 30 years old",
"% households moved <10 years ago",
"% multiunit structures",
"% owner occupied housing",
"% vacant housing",
"% > 60 years old",
"% < 18 years old",
"% white",
"% Asian",
"% Hispanic",
"% black",
"% foreign born"
],
'NumOfMaps': 18,
'Initial_map_center':[41.82, -87.85],
'Initial_map_zoom_level':9,
'SortLayers': "compare", # Enter “compare” or “temporal”. compare mode is for comparing variables at a specific point of time.
# temporal mode is for displaying spatiotemporal patterns of the same variable using multiple maps.
#'InitialLayers':["1980_% nonhisp white persons", "1990_% nonhisp white persons", "2000_% nonhisp white persons", "2010_% nonhisp white persons"],
'Map_width':"400px",
'Map_height':"480px"
}
Adaptive_Choropleth_Mapper_viz(param_CHI)
input_attr_CHI.columns