for p in export_static(load_sol_geo()): print(p)Export Static Data
SolomonGeo data to static JSON/GeoJSON files used by the Astro + MapLibre site in web/.
The static site in web/ has no Python server, so all of the data it needs is exported here once and committed to web/public/data/. The export reuses the existing SolomonGeo class, so the numbers match the Dash app exactly. Re-run this whenever the source data changes:
python -m SolomonIslandsDataMap.export_static # build from the local testData/ files
python -m SolomonIslandsDataMap.export_static --aws # build from the pickle stored in AWS S3Loading the data
load_sol_geo
def load_sol_geo(
aws:bool=False, # Load the pickle from AWS S3 rather than building from `testData/`
)->SolomonGeo:Load the SolomonGeo object, either from AWS or from the local test data
Converting the data
export_geojson
def export_geojson(
sg:SolomonGeo, # The data object
)->dict: # Geo level -> GeoJSON feature collectionSimplified geographies for each geography level, the feature name is the location name
export_census
def export_census(
sg:SolomonGeo
)->dict:Census values for every location as {geo: {location: {Total: [...], Proportion: [...]}}}. The value arrays line up with columns, a list of [variable, measure] pairs.
export_population
def export_population(
sg:SolomonGeo
)->dict:Population projection rows (Province only). Each row is [location, year, age, type, *values] where the values line up with measures, the measures of the Population variable.
export_elections
def export_elections(
sg:SolomonGeo
)->dict:Election results, one row per candidate, plus the winning party per location
export_meta
def export_meta(
sg:SolomonGeo
)->dict:Lists used to build the filters on the site
Writing the files
export_static
def export_static(
sg:SolomonGeo, # The data object
out_dir:Path=None, # Folder to write to, defaults to `web/public/data`
)->list: # The paths writtenWrite all of the static data files used by the website
main
def main():Call self as a function.
Run the export from the notebook (not run by nbdev_test, as it writes files):