lczlite

Local Climate Zone (LCZ, Stewart & Oke 2012) classification from urban canopy parameters: fuzzy range scoring with confidence and mixed-class flags, building footprint grids and WUDAPT codes.

Version 0.1.2 · Python >=3.9 · MIT licence
pip install lczlite
PyPISourceIssuesChangelogCite (DOI)

lczlite

PyPI version Python versions pipeline status License: MIT DOI Downloads

Local Climate Zone classification from urban canopy parameters.

lczlite assigns sites or grid cells to the Local Climate Zones of Stewart & Oke (2012) by comparing their urban canopy parameters with the property ranges of each zone:

It needs only NumPy. A command-line tool is included.

The default range table holds the values of Stewart & Oke (2012), Table 3 (sky view factor, aspect ratio, building / impervious / pervious surface fraction, height of roughness elements, terrain roughness class) and Table 4 (surface admittance, albedo, anthropogenic heat), read from the published article and shipped as lczlite/data/stewart_oke_2012.json. Surface fractions are converted from percent to 0-1. Two cells are blank in the paper and stay blank: the admittance of LCZ A ("unknown") and the height of roughness elements of LCZ G.

Installation

pip install lczlite

Requires Python 3.9 or newer.

Quickstart

import numpy as np
import lczlite as lz

table = lz.stewart_oke_table()     # Stewart & Oke (2012), Tables 3-4
# or a local adaptation: lz.read_range_table("my_ranges.csv", percent=True)

# Parameters per site (any shape; NaN = unknown)
params = {
    "svf": [0.45, 0.75, 0.95],
    "aspect_ratio": [1.2, 0.5, 0.05],
    "bsf": [0.50, 0.30, 0.03],
    "isf": [0.40, 0.30, 0.02],
    "psf": [0.10, 0.40, 0.95],
    "height": [15.0, 6.0, 0.5],
}
res = lz.classify(params, table, mixed_margin=0.1)
res.labels          # best LCZ key per site, '' = unclassified
res.codes           # WUDAPT codes 1-17, 0 = unclassified
res.confidence      # best score (0-1)
res.margin          # gap to the runner-up
res.mixed           # True where the two best classes are close
res.explain(0)      # per-parameter memberships of site 0
lz.class_summary(res)

From building footprints to classified cells:

spec = lz.GridSpec(x0=500000, y0=4300000, cell_size=200, shape=(50, 50))
grid = lz.buildings_to_grid(x, y, footprint_area, height, spec)
params = grid.parameters(impervious_area, height="mean",
                         admittance=adm, albedo=alb, anthropogenic_heat=qf)
res = lz.classify(params, table)
rgb = res.to_rgb()                 # (rows, cols, 3) uint8
lz.write_qml("lcz.qml")            # palette for a WUDAPT-coded GeoTIFF in QGIS

A complete synthetic run is in examples/quickstart.py.

Feature overview

Area Functions / classes
Classes LCZ_CLASSES, LCZ_KEYS, normalize_key, wudapt_code, key_from_code, lcz_class
Colours colour_table, to_rgb, hex_to_rgb, write_qml, write_colour_csv
Range tables RangeTable, Range, parse_range, stewart_oke_table, read_range_table, write_template, PARAMETERS
Parameters surface_fractions, street_width_regular, aspect_ratio, svf_canyon, frontal_area_index, macdonald, roughness_class, albedo_plan_weighted, canopy_parameters, DAVENPORT_Z0
Grids GridSpec, buildings_to_grid -> BuildingGrid (parameters())
Classification membership, classify -> LCZResult (labels, codes, confidence, margin, mixed, explain, records, to_rgb)
Summaries class_summary, mixed_pairs, compare_maps, majority_filter
I/O read_sites_csv, result_rows, write_results_csv, write_csv

Parameter names: svf, aspect_ratio, bsf (building surface fraction), isf (impervious), psf (pervious), height (height of roughness elements), roughness_class, admittance, albedo, anthropogenic_heat; common long names are accepted as aliases. Surface fractions are 0-1 inside the package; use percent=True for tables or site files in percent.

Methods and sources

Local Climate Zones. Seventeen classes (built types 1-10, land-cover types A-G) defined by ranges of geometric, surface-cover, thermal, radiative and metabolic properties (Stewart & Oke 2012). WUDAPT products store them as integers 1-17 with A-G as 11-17 (Demuzere et al. 2021); the default colours follow the palette commonly used for WUDAPT maps and can be overridden.

Scoring. For a range [lo, hi] the membership is 1 inside and falls linearly to 0 at a distance w outside; w = softness · (hi − lo) for two-sided ranges, softness · |bound| for one-sided ones, or an absolute tolerance per parameter. A class score is the weighted mean membership over the parameters the class constrains and the site has. The best class gives the confidence; the margin to the second class drives the mixed flag. The membership shape and the defaults (softness=0.5, mixed_margin=0.1, min_score=0) are design choices of this package, not values from the paper.

Parameters.

Parameter Computation Source
BSF, ISF, PSF plan-area shares of the cell; PSF = remainder unless given definition
Street width W = L (1/√λp − 1), L = √(mean footprint) regular array of square blocks (assumption of this package)
Aspect ratio H / W definition
SVF, floor-averaged √(1 + (H/W)²) − H/W infinite canyon, Hottel's crossed-strings rule
SVF, floor centre cos(arctan(2H/W)) Oke (1987)
λf frontal area / cell area; default frontal width √footprint definition
zd, z0 zd/H = 1 + A^(−λp)(λp − 1), z0/H = (1 − zd/H) exp(−(0.5 β C_D/κ² (1 − zd/H) λf)^(−1/2)), A = 4.43, β = 1.0, C_D = 1.2, κ = 0.4 (staggered arrays) Macdonald, Griffiths & Hall (1998)
Roughness class Davenport class whose nominal z0 (0.0002, 0.005, 0.03, 0.10, 0.25, 0.5, 1.0, ≥2 m) is nearest on a log scale Davenport et al. (2000); nearest-class rule is this package's convention. Stewart & Oke (2012, Table 5) print 0.0005 m for class 2; 0.005 m is the Davenport-Wieringa value
Albedo (optional) plan-area-weighted component albedos approximation, ignores canyon trapping
Admittance, anthropogenic heat passed through user data

Buildings are assigned whole to the cell containing their reference point.

Values left to the user

Command line

lczlite ranges -o so2012.csv                       # bundled Stewart & Oke ranges as CSV
lczlite template lcz_ranges.csv                    # empty 17-class table for local ranges
lczlite grid buildings.csv --cell-size 200 -o cells.csv      # x,y,area,height -> cells
# add impervious_area (and optional albedo, admittance, ...) to cells.csv, then:
lczlite params cells.csv --height-col height_geometric -o params.csv
lczlite classify params.csv \
    --weights svf=2 --mixed-margin 0.1 --scores -o lcz.csv --summary summary.json
lczlite colours --qml lcz.qml --csv lcz_colours.csv

params expects cell_area, building_area, impervious_area and a height column, and uses mean_footprint, street_width, frontal_area, svf, pervious_area, admittance, albedo, anthropogenic_heat when present.

Limitations

References

Academic citation

@software{eminoglu_lczlite,
  author  = {Eminoğlu, Yusuf},
  title   = {lczlite},
  year    = {2026},
  version = {0.1.2},
  doi     = {10.5281/zenodo.24235562},
  url     = {https://gitlab.com/geophilo1/lczlite_sdk}
}

Related Geophilo SDKs

License

MIT, see LICENSE.

Other Geophilo SDKs