Data access for developers
Everything on the portal has a stable web address. Download the files, read the portal's data services, or load the data straight into Python, R, DuckDB or QGIS.
Downloads
Ghana's boundaries, free to download. Every unit carries an OCHA p-code: join tables on p-codes, never on names. Downloads need a free account.
Data services
National indicators
The freshest figure for each indicator: World Bank history, with the IMF's newer figures for recent years where the World Bank has not published yet.
GET {SITE}/api/series?code=NY.GDP.MKTP.KD.ZG&countries=GHA,NGA,CIVThe indicator codes are the World Bank's; the list the portal uses is in indicators.json. The World Bank's own API works too, with no key: https://api.worldbank.org/v2/country/GHA/indicator/SP.POP.TOTL?format=json.
Catalogue and geography
The files the portal itself reads. They are stable and safe to build on.
Python
import geopandas as gpd
import pandas as pd
import requests
districts = gpd.read_file("{DATA}/reference/gha_admin2.geojson")
# Area in km² in a metric CRS (UTM 30N), not in degrees
districts["area_km2"] = districts.to_crs(32630).area / 1e6
# A national indicator, freshest source first
series = requests.get("{SITE}/api/series", params={"code": "SP.POP.TOTL", "countries": "GHA"}).json()
population = pd.DataFrame([p[:2] for p in series["series"]["GHA"]], columns=["year", "population"])R
library(sf)
library(jsonlite)
districts <- st_read("{DATA}/reference/gha_admin2.geojson")
districts$area_km2 <- as.numeric(st_area(st_transform(districts, 32630))) / 1e6
series <- fromJSON("{SITE}/api/series?code=NY.GDP.MKTP.KD.ZG&countries=GHA")
growth <- as.data.frame(series$series$GHA)[, 1:2]
names(growth) <- c("year", "growth")DuckDB
DuckDB reads the files straight from the web, with no server and nothing to install beyond DuckDB itself.
INSTALL spatial; LOAD spatial;
SELECT adm1_name AS region, count(*) AS districts
FROM ST_Read('{DATA}/reference/gha_admin2.geojson')
GROUP BY 1
ORDER BY 2 DESC;The same engine runs in your browser in the Data Lab.
QGIS
- Layer › Add Layer › Add Vector Layer
- Choose Protocol: HTTP(S) and paste a GeoJSON address from the downloads above
- For satellite layers, add an XYZ Tiles connection with the address on the dataset page
Map links
A report, a notebook or a lesson can open the GIS workspace on exactly the map it talks about, for example Accra at night:
The map behind it is a .geolibre file the portal writes on request, from a few parameters: layers (national, regions, districts, capitals), eo (a satellite layer from the data browser), bbox (west, south, east, north), date and title:
Citing
Credit the original producer of each dataset, using the credit line on its page; the Cite tab there has a ready-made reference. More guidance, and how to share your own data, is in the documentation.