momepy API reference#

elements#

Blocks(tessellation, edges, buildings, ...)

Generate blocks based on buildings, tessellation, and street network.

buffered_limit(gdf[, buffer])

Define limit for momepy.Tessellation as a buffer around buildings.

COINS(edge_gdf[, angle_threshold])

Calculates natural continuity and hierarchy of street networks in a given GeoDataFrame using the COINS algorithm.

enclosures(primary_barriers[, limit, ...])

Generate enclosures based on passed barriers.

get_network_id(left, right, network_id[, ...])

Snap each element (preferably building) to the closest street network segment and save its ID.

get_network_ratio(df, edges[, initial_buffer])

Link polygons to network edges based on the proportion of overlap (if a cell intersects more than one edge).

get_node_id(objects, nodes, edges, node_id)

Snap each building to the closest street network node on the closest network edge.

Tessellation(gdf, unique_id[, limit, ...])

Generates tessellation.

dimension#

Area(gdf)

Calculates the area of each object in a given GeoDataFrame.

AverageCharacter(gdf, values, ...[, rng, ...])

Calculates the average of a character within a set neighbourhood defined in spatial_weights.

CourtyardArea(gdf[, areas])

Calculates area of holes within geometry - area of courtyards.

CoveredArea(gdf, spatial_weights, unique_id)

Calculates the area covered by neighbours, which is total area covered by neighbours defined in spatial_weights and the element itself.

FloorArea(gdf, heights[, areas])

Calculates floor area of each object based on height and area.

LongestAxisLength(gdf)

Calculates the length of the longest axis of object.

Perimeter(gdf)

Calculates perimeter of each object in a given GeoDataFrame.

PerimeterWall(gdf[, spatial_weights, verbose])

Calculate the perimeter wall length of the joined structure.

SegmentsLength(gdf[, spatial_weights, mean, ...])

Calculate the cummulative and/or mean length of segments.

StreetProfile(left, right[, heights, ...])

Calculates the street profile characters.

Volume(gdf, heights[, areas])

Calculates the volume of each object in a given GeoDataFrame based on its height and area.

WeightedCharacter(gdf, values, ...[, areas, ...])

Calculates the weighted character.

shape#

CentroidCorners(gdf[, verbose])

Calculates the mean distance centroid - corners and standard deviation.

CircularCompactness(gdf[, areas])

Calculates the compactness index of each object in a given GeoDataFrame.

CompactnessWeightedAxis(gdf[, areas, ...])

Calculates the compactness-weighted axis of each object in a given GeoDataFrame.

Convexity(gdf[, areas])

Calculates the Convexity index of each object in a given GeoDataFrame.

Corners(gdf[, verbose])

Calculates the number of corners of each object in a given GeoDataFrame.

CourtyardIndex(gdf, courtyard_areas[, areas])

Calculates the courtyard index of each object in a given GeoDataFrame.

Elongation(gdf)

Calculates the elongation of each object seen as elongation of its minimum bounding rectangle.

EquivalentRectangularIndex(gdf[, areas, ...])

Calculates the equivalent rectangular index of each object in a given GeoDataFrame.

FormFactor(gdf, volumes[, areas, heights])

Calculates the form factor of each object in a given GeoDataFrame.

FractalDimension(gdf[, areas, perimeters])

Calculates fractal dimension of each object in given GeoDataFrame.

Linearity(gdf[, verbose])

Calculates the linearity of each LineString object in a given GeoDataFrame.

Rectangularity(gdf[, areas])

Calculates the rectangularity of each object in a given GeoDataFrame.

ShapeIndex(gdf, longest_axis[, areas])

Calculates the shape index of each object in a given GeoDataFrame.

SquareCompactness(gdf[, areas, perimeters])

Calculates the compactness index of each object in a given GeoDataFrame.

Squareness(gdf[, verbose])

Calculates the squareness of each object in a given GeoDataFrame. Uses only external shape (shapely.geometry.exterior), courtyards are not included. Returns np.nan for MultiPolygons.

VolumeFacadeRatio(gdf, heights[, volumes, ...])

Calculates the volume/facade ratio of each object in a given GeoDataFrame.

spatial distribution#

Alignment(gdf, spatial_weights, unique_id, ...)

Calculate the mean deviation of solar orientation of objects on adjacent cells from an object.

BuildingAdjacency(gdf, ...[, ...])

Calculate the level of building adjacency.

CellAlignment(left, right, ...)

Calculate the difference between cell orientation and the orientation of object.

MeanInterbuildingDistance(gdf, ...[, ...])

Calculate the mean interbuilding distance.

NeighborDistance(gdf, spatial_weights, unique_id)

Calculate the mean distance to adjacent buildings (based on spatial_weights).

NeighboringStreetOrientationDeviation(gdf)

Calculate the mean deviation of solar orientation of adjacent streets.

Neighbors(gdf, spatial_weights, unique_id[, ...])

Calculate the number of neighbours captured by spatial_weights.

Orientation(gdf[, verbose])

Calculate the orientation of object.

SharedWalls(gdf)

Calculate the length of shared walls of adjacent elements (typically buildings).

SharedWallsRatio(gdf[, perimeters])

Calculate shared walls ratio of adjacent elements (typically buildings).

StreetAlignment(left, right, orientations[, ...])

Calculate the difference between street orientation and orientation of another object in degrees.

intensity#

AreaRatio(left, right, left_areas, right_areas)

Calculate covered area ratio or floor area ratio of objects.

BlocksCount(gdf, block_id, spatial_weights, ...)

Calculates the weighted number of blocks.

Count(left, right, left_id, right_id[, weighted])

Calculate the number of elements within an aggregated structure.

Courtyards(gdf[, spatial_weights, verbose])

Calculate the number of courtyards within the joined structure.

Density(gdf, values, spatial_weights, unique_id)

Calculate the gross density.

NodeDensity(left, right, spatial_weights[, ...])

Calculate the density of nodes neighbours on street network defined in spatial_weights.

Reached(left, right, left_id, right_id[, ...])

Calculates the number of objects reached within neighbours on a street network.

graph#

betweenness_centrality(graph[, name, mode, ...])

Calculates the shortest-path betweenness centrality for nodes.

cds_length(graph[, radius, mode, name, ...])

Calculates length of cul-de-sacs for subgraph around each node if radius is set, or for whole graph, if radius=None.

closeness_centrality(graph[, name, weight, ...])

Calculates the closeness centrality for nodes.

clustering(graph[, name])

Calculates the squares clustering coefficient for nodes.

cyclomatic(graph[, radius, name, distance, ...])

Calculates cyclomatic complexity for subgraph around each node if radius is set, or for whole graph, if radius=None.

edge_node_ratio(graph[, radius, name, ...])

Calculates edge / node ratio for subgraph around each node if radius is set, or for whole graph, if radius=None.

gamma(graph[, radius, name, distance, verbose])

Calculates connectivity gamma index for subgraph around each node if radius is set, or for whole graph, if radius=None.

mean_node_degree(graph[, radius, name, ...])

Calculates mean node degree for subgraph around each node if radius is set, or for whole graph, if radius=None.

mean_node_dist(graph[, name, length, verbose])

Calculates mean distance to neighbouring nodes.

mean_nodes(G, attr)

Calculates mean value of nodes attr for each edge.

meshedness(graph[, radius, name, distance, ...])

Calculates meshedness for subgraph around each node if radius is set, or for whole graph, if radius=None.

node_degree(graph[, name])

Calculates node degree for each node.

proportion(graph[, radius, three, four, ...])

Calculates the proportion of intersection types for subgraph around each node if radius is set, or for whole graph, if radius=None.

straightness_centrality(graph[, weight, ...])

Calculates the straightness centrality for nodes.

subgraph(graph[, radius, distance, ...])

Calculates all subgraph-based characters.

diversity#

Gini(gdf, values, spatial_weights, unique_id)

Calculates the Gini index of values within neighbours defined in spatial_weights.

Percentiles(gdf, values, spatial_weights, ...)

Calculates the percentiles of values within neighbours defined in spatial_weights.

Range(gdf, values, spatial_weights, unique_id)

Calculates the range of values within neighbours defined in spatial_weights.

Shannon(gdf, values, spatial_weights, unique_id)

Calculates the Shannon index of values within neighbours defined in spatial_weights.

Simpson(gdf, values, spatial_weights, unique_id)

Calculates the Simpson's diversity index of values within neighbours defined in spatial_weights.

Theil(gdf, values, spatial_weights, unique_id)

Calculates the Theil measure of inequality of values within neighbours defined in spatial_weights.

Unique(gdf, values, spatial_weights, unique_id)

Calculates the number of unique values within neighbours defined in spatial_weights.

shannon_diversity(data[, bins, categorical, ...])

Calculates the Shannon's diversity index of data.

simpson_diversity(values[, bins, categorical])

Calculates the Simpson's diversity index of data.

spatial weights#

DistanceBand(gdf, threshold[, centroid, ids])

On demand distance-based spatial weights-like class.

sw_high(k[, gdf, weights, ids, contiguity, ...])

Generate spatial weights based on Queen or Rook contiguity of order k.

preprocessing#

close_gaps(gdf, tolerance)

Close gaps in LineString geometry where it should be contiguous.

CheckTessellationInput(gdf[, shrink, ...])

Check input data for Tessellation for potential errors.

extend_lines(gdf, tolerance[, target, ...])

Extends lines from gdf to itself or target within a set tolerance

remove_false_nodes(gdf)

Clean topology of existing LineString geometry by removal of nodes of degree 2.

preprocess(buildings[, size, compactness, ...])

Preprocesses building geometry to eliminate additional structures being single features.

roundabout_simplification(edges[, polys, ...])

Selects the roundabouts from polys to create a center point to merge all incoming edges.

utilities#

gdf_to_nx(gdf_network[, approach, length, ...])

Convert a LineString GeoDataFrame to a networkx.MultiGraph or other Graph as per specification.

limit_range(vals, rng)

Extract values within selected range.

nx_to_gdf(net[, points, lines, ...])

Convert a networkx.Graph to a LineString GeoDataFrame and Point GeoDataFrame.

unique_id(objects)

Add an attribute with a unique ID to each row of a GeoDataFrame.