CityMetrix¶
CityMetrix (city_metrix) is a Python package from WRI's Cities Indicators Framework (CIF) for extracting geospatial data layers and computing urban sustainability metrics for any city or custom area of interest, using global open datasets.
It answers two related questions for any urban geography you care about:
- What does the data look like here? — pull a raw or processed geospatial layer (land cover, tree canopy, elevation, air quality, building footprints, flood risk, ...) clipped to your area.
- How does this area score? — compute a pre-defined indicator (e.g. mean tree cover, % impervious surface, PM2.5 exposure) as zonal statistics over your area.
Two ways to define "where"¶
Every layer and metric takes an area of interest (AOI) as input, in one of two forms:
- A polygon — any
GeoDataFrameor bounding box you already have. - A city ID — a WRI city identifier plus an AOI type (
city_centroid,urban_extent, orcity_admin_level), resolved automatically against the Cities Data API.
See Defining an AOI for details.
A 30-second example¶
from city_metrix.layers import TreeCover, EsaWorldCover, EsaWorldCoverClass
from city_metrix.metrics import MeanTreeCover__Percent
# 1. Define an AOI as a polygon (any GeoDataFrame works)
import geopandas as gpd
city_gdf = gpd.read_file("jakarta.geojson")
# 2. Pull a layer, masked to built-up land, and aggregate it yourself
tree_in_builtup = (
TreeCover(min_tree_cover=10)
.mask(EsaWorldCover(land_cover_class=EsaWorldCoverClass.BUILT_UP))
.groupby(city_gdf)
.count()
)
# 3. ...or just use a pre-built metric
mean_cover = MeanTreeCover__Percent().get_metric(city_gdf)
Where to go next¶
- New to the package? Start with Installation and the Quickstart.
- Want to understand the moving parts? Read Core Concepts.
- Looking for a specific dataset or indicator? Jump straight to the Layers reference or Metrics reference.