momepy

raw JSON →
0.11.0 verified Fri May 01 auth: no python

Urban Morphology Measuring Toolkit (momepy) is a Python library for measuring and analyzing urban morphology. Current version is 0.11.0, requiring Python >=3.11. Releases are roughly quarterly, with a focus on GIS integration via GeoPandas and libpysal.

pip install momepy
error AttributeError: module 'momepy' has no attribute 'Area'
cause The old class-based API was replaced with functions in v0.8.0.
fix
Use momepy.area(tessellation) instead of momepy.Area(tessellation).
error TypeError: morphological_tessellation() got an unexpected keyword argument 'simplify'
cause The `simplify` keyword was added in v0.10.0. Older versions do not have it.
fix
Upgrade momepy to v0.10.0 or later: pip install momepy>=0.10.0
error ValueError: CRS is not set. Please set a CRS on the GeoDataFrame.
cause momepy functions require a valid CRS; input had no CRS.
fix
Set CRS: gdf.set_crs(epsg=4326, inplace=True) before passing to momepy.
error ImportError: cannot import name 'Continuity' from 'momepy'
cause Continuity was added in v0.11.0. Older versions do not have it.
fix
Upgrade to v0.11.0: pip install -U momepy. Then use from momepy import Continuity.
error UserWarning: Geodataframe has no CRS. Assuming EPSG:3857.
cause CRS is missing and momepy defaults to Web Mercator; results may be incorrect if input is in a different CRS.
fix
Explicitly set CRS on input: gdf = gdf.set_crs(epsg=4326).to_crs(epsg=3857).
breaking In v0.8.0, the core measurement classes were replaced with functions that depend on libpysal.Graph. Old code using classes like `momepy.Area` or `momepy.Compactness` will break.
fix Migrate to the new functional API. See migration guide: http://docs.momepy.org/en/latest/user_guide/migration.html
deprecated Deprecation of preprocessing tooling (e.g., `remove_false_nodes`, `close_gaps`) in v0.11.0; these will be removed before 1.0.
fix Use alternative approaches: for false nodes, consider using `libpysal.graph.remove_false_nodes`; for gap closing, handle with shapely directly.
gotcha momepy functions often return a new GeoDataFrame with a new index; do not assume the original index is preserved. Always join or map back using the geometry or original ID column.
fix If preserving original IDs, ensure your input data has a unique ID column (e.g., 'ID') and use that for merging after momepy operations.
gotcha momepy requires input geodataframes to have a 'geometry' column with a valid CRS and that all geometries are in the same projection (usually projected CRS, not lonlat). Missing CRS or geographic CRS can cause errors or nonsensical results.
fix Use `gdf.to_crs(epsg=3857)` (or appropriate local UTM) before passing to momepy functions.
breaking Python 3.11 or higher is required as of v0.11.0; earlier versions (3.10, 3.9) are no longer supported.
fix Upgrade Python to 3.11 or newer.
deprecated The old `momepy.graph` and `momepy.network` modules are deprecated in favor of libpysal.Graph-based analysis introduced in v0.8.0.
fix Use `libpysal.graph.Graph` and the new graph-related momepy functions like `momepy.node_degree`.
gotcha When using `momepy.Streetscape`, missing values in OSM queries are treated as 0 in averaging, which can bias results. Check v0.9.1 release note: 'Get mean of actual values (do not imply missing == 0)' was a bug that may reappear if old code is used.
fix If using streetscape, ensure you are on latest version and verify handling of missing values.

This quickstart loads a sample dataset, generates a morphological tessellation (Voronoi-like cells from building footprints), and calculates the area of each cell.

import geopandas as gpd
import momepy

# Load sample buildings from momepy
buildings = gpd.read_file(momepy.datasets.get_path('bubenec'))

# Generate morphological tessellation
tessellation = momepy.morphological_tessellation(buildings)

# Compute area of tessellation cells
tessellation['area'] = tessellation.geometry.area
print(tessellation.head())