Consistent, comparable, authoritative data describing sub-national variation is a constant point of complication for World Bank teams, our development partners, and client countries when assessing and investigating economic issues and national policy. This project will focus on creating and disseminating such data through aggregation of geospatial information at standard administrative divisions, and through the attribution of household survey data with foundational geospatial variables.
docker-compose up -d
db.env
file:PGHOST=localhost
PGPORT=5439
PGDATABASE=postgis
PGUSER=username
PGPASSWORD=password
PGTABLENAME=space2stats
./postgres/download_parquet.sh
./load_to_prod.sh
You can get started with a subset of data for NYC with
./load_nyc_sample.sh
which requires changing yourdb.env
value forPGTABLENAME
tospace2stats_nyc_sample
.
The API can be run with:
python -m space2stats
The module can be installed via pip
directly from Github:
pip install "git+https://github.com/worldbank/DECAT_Space2Stats.git#subdirectory=space2stats_api/src"
It can then be used within Python as such:
from space2stats import StatsTable
with StatsTable.connect() as stats_table:
...
Connection parameters may be explicitely provided. Otherwise, connection parameters will expected to be available via standard PostgreSQL Environment Variables.
from space2stats import StatsTable
with StatsTable.connect(
PGHOST="localhost",
PGPORT="5432",
PGUSER="postgres",
PGPASSWORD="changeme",
PGDATABASE="postgis",
PGTABLENAME="space2stats",
) as stats_table:
...
# alternatively:
# settings = Settings(
# PGHOST="localhost",
# PGPORT="5432",
# PGUSER="postgres",
# PGPASSWORD="changeme",
# PGDATABASE="postgis",
# PGTABLENAME="space2stats",
# )
# with StatsTable.connect(settings):
# ...