momepy.alignment#

momepy.alignment(orientation, graph)[source]#

Calculate the mean deviation of orientation adjacent elements

\[\frac{1}{n}\sum_{i=1}^n dev_i=\frac{dev_1+dev_2+\cdots+dev_n}{n}\]

Takes orientation of adjacent elements defined in graph and calculates the mean deviation.

Parameters:
orientationSeries

A series containing orientation (e.g. measured by the orientation() function) indexed using the same index that has been used to build the graph.

graphlibpysal.graph.Graph

Graph representing spatial relationships between elements.

Returns:
Series

Notes

The index of orientation must match the index along which the graph is built.

Examples

>>> from libpysal import graph
>>> path = momepy.datasets.get_path("bubenec")
>>> buildings = geopandas.read_file(path, layer="buildings")
>>> orientation = momepy.orientation(buildings)

Define a spatial graph that includes observations within its own neighborhood:

>>> delaunay = graph.Graph.build_triangulation(
...     buildings.centroid
... ).assign_self_weight()
>>> delaunay
<Graph of 144 nodes and 970 nonzero edges indexed by
 [0, 1, 2, 3, 4, ...]>

Alignment of orienation within triangulated neighbors:

>>> momepy.alignment(orientation, delaunay)
0      14.639585
1       0.217417
2       0.205626
3       0.151730
4       0.352692
         ...
139     1.970642
140     0.127322
141     0.161906
142     4.350890
143     0.084884
Name: alignment, Length: 144, dtype: float64