momepy API reference#
The current version of momepy includes two implementations of most of the functionality due to the ongoing migration period moving from the legacy class-based API to a new function-based API. This page outlines the stable API. For the legacy functionality, see Legacy API.
Managing morphological elements#
Momepy allows creation of a small subset of bespoke morphological geometric features.
|
Generate morphological tessellation. |
|
Generate enclosed tessellation |
|
Generate enclosures based on passed barriers. |
|
Generate blocks based on buildings, tessellation, and street network. |
Additionally, it contains tools supporting these.
|
Define limit for tessellation as a buffer around buildings. |
|
Check whether result matches buildings and contains only Polygons. |
And tools linking various elements together.
|
Identify the nearest street for each building. |
|
Identify the nearest node for each building. |
|
Link polygons to network edges based on the proportion of overlap (if a cell intersects more than one edge). |
Measuring dimension#
A set of functions to measure dimensions of geometric elements:
|
Calculates area of holes within geometry - area of courtyards. |
|
Calculates floor area of each object based on height and area. |
|
Calculates the length of the longest axis of object. |
|
Calculate the perimeter wall length of the joined structure. |
|
Calculates the street profile characters. |
|
Calculates volume of each object in given GeoDataFrame based on its height and area. |
|
Calculates the weighted character. |
Measuring shape#
A set of functions to measure shape of geometric elements:
|
Calculates the centroid-corner distance of each object given its geometry. |
|
Calculates the circular compactness of each object given its geometry. |
|
Calculates the compactness-weighted axis of each object in a given GeoDataFrame. |
|
Calculates the convexity of each object given its geometry. |
|
Calculates the number of corners of each object given its geometry. |
|
Calculates the courtyard index of each object given its geometry. |
|
Calculates the elongation of each object given its geometry. |
|
Calculates the equivalent rectangular index of each object given its geometry. |
|
Calculates the facade ratio of each object given its geometry. |
|
Calculates the form factor of each object given its geometry and height. |
|
Calculates fractal dimension based on area and perimeter. |
|
Calculates the linearity of each LineString |
|
Calculates the rectangularity of each object given its geometry. |
|
Calculates the shape index of each object given its geometry. |
|
Calculates the square compactness of each object given its geometry. |
|
Calculates the squareness of each object given its geometry. |
Measuring spatial distribution#
A set of functions to measure spatial distribution of geometric elements:
|
Calculate the mean deviation of orientation adjacent elements |
|
Calculate the level of building adjacency. |
|
Calculate the difference between cell orientation and the orientation of object. |
|
Calculate the mean distance between adjacent geometries within a set neighborhood |
|
Calculate the mean distance to adjacent elements. |
|
Calculate the number of neighbours captured by |
|
Calculate the orientation of objects. |
|
Calculate the length of shared walls of adjacent elements (typically buildings). |
|
Calulate the deviation of the building orientation from the street orientation. |
Measuring intensity#
A set of functions to measure intensity characters:
|
Calculate the number of courtyards within the joined structure. |
Note that additional intensity characters can be directly derived using libpysal.graph.Graph.describe()
and functions describe_agg()
and describe_reached_agg()
.
Measuring diversity#
A set of functions to measure spatial diversity of elements and their values:
|
Describe the distribution of values within the groups of an aggregation. |
|
Describe the distribution of values reached on a neighbourhood graph. |
|
Calculates the Gini index of values within neighbours defined in |
|
Calculates linearly weighted percentiles of |
|
Calculates the Shannon index of values within neighbours defined in |
|
Calculates the Simpson's diversity index of values within neighbours defined in |
|
Calculates the Theil measure of inequality of values within neighbours defined in |
|
Calculates the range of values within neighbours defined in |
|
Calculate the mean deviation of each |
Note that additional diversity characters can be directly derived using libpysal.graph.Graph.describe()
.
Underlying components of shannon()
and simpson()
are also exposed for direct use:
|
Calculates the Shannon's diversity index of data. |
|
Calculates the Simpson's diversity index of data. |
Measuring connectivity#
A set of functions for the analysis of connectivity and configuration of street networks:
|
Calculates the shortest-path betweenness centrality for nodes. |
|
Calculates length of cul-de-sacs for subgraph around each node if radius is set, or for whole graph, if |
|
Calculates the closeness centrality for nodes. |
|
Calculates the squares clustering coefficient for nodes. |
|
Calculates cyclomatic complexity for subgraph around each node if radius is set, or for whole graph, if |
|
Calculates edge / node ratio for subgraph around each node if radius is set, or for whole graph, if |
|
Calculates connectivity gamma index for subgraph around each node if radius is set, or for whole graph, if |
|
Calculates mean node degree for subgraph around each node if radius is set, or for whole graph, if |
|
Calculates mean distance to neighbouring nodes. |
|
Calculates mean value of nodes attr for each edge. |
|
Calculates meshedness for subgraph around each node if radius is set, or for whole graph, if |
|
Calculates node degree for each node. |
|
Calculate the density of a node's neighbours (for all nodes) on the street network defined in |
|
Calculates the proportion of intersection types for subgraph around each node if radius is set, or for whole graph, if |
|
Calculates the straightness centrality for nodes. |
|
Calculates all subgraph-based characters. |
|
Calculates natural continuity and hierarchy of street networks in a given GeoDataFrame using the COINS algorithm. |
With utilities allowing conversion between networkx objects and GeoPandas objects.
Measuring streetscape#
Specialised class for the advanced streetscape analysis.
|
Streetscape analysis based on sightlines |
|
Compute plot-based characters |
|
Compute slope-based characters |
Extract data on a street level. |
|
Extract data on a sightline point level. |
Data preprocessing#
Most of the algorithms have certain expectations about the quality of input data. The preprocessing module helps adapting the input data and fixing common issues.
|
Close gaps in LineString geometry where it should be contiguous. |
|
Extends lines from gdf to itself or target within a set tolerance |
|
Clean topology of existing LineString geometry by removal of nodes of degree 2. |
|
Consolidate close street intersections into a single node, collapsing short edges. |
|
Selects the roundabouts from |
Additionally, there are methods for data assessment.
|
Check input data for |
|
Identify face artifacts in street networks. |
Further analysis can be done directly using methods available in libpysal.graph.Graph
.