esda.shape.second_moment_of_area¶
- esda.shape.second_moment_of_area(collection, normalize=False, ref_pt=None)¶
Compute moment of inertia (second moment of area) per geometry.
- Parameters:
- collection
GeoSeries,GeoDataFrame,numpy.ndarray,list Input collection of polygons or multipolygons.
- normalizebool, optional
If True, returns moment normalized by reference cricle of same area. Default is False.
- ref_pt
GeoSeries,ShapelyPointorlistofPoints, array_like of shape (2,) or (n, 2), optional If provided, shifts moment to be with respect to this point or points. The default behavior (default:
None) is to calculate the moment about the centroid of each geometry. Points may be passed as as array-like of coordinates or point geometries. If a single point, all moments are calculated with respect to that reference point. If of length equal to collection, the moment for each geometry in collection is calculated with respect to the reference point with the same index. To return moment about the origin, explicitly set to (0, 0).
- collection
- Returns:
numpy.ndarrayArray of moment of inertia values for each geometry in the collection.
Notes
Calculates the moment of inertia of each geometry in the collection. Can handle polygons with holes and multipolygons by summing the moments of inertia of each part. The moment of inertia is calculated about the centroid of each geometry by default, but can also be calculated about a specified reference point or points.
The moment of inertia is the variance of the distance of all points in a shape to a reference point, which can be interpreted as an axis of rotation perpendicular to the plane of the shape. The first parameter should be a GeoDataFrame or array-like of Polygons or MultiPolygons. If normalization is requested, the moment of inertia is compared with that of a circle of equal area. This is discussed in detail below.
Moments of inertia with weights (such as population) may be calculated using moment_of_inertia_regions. Without weights, the moment of inertia is known as the area moment of inertia or the second moment of area, and can be quickly calculated from the polygon vertices using the shoelace formula. The second moments of area about the x and y axes are calculated as:
\[ \begin{align}\begin{aligned}I_x = \frac{1}{12}\sum_{i=0}^{n-1} (x_i y_{i+1} - x_{i+1}y_i)(y_i^2 + y_i y_{i+1} + y_{i+1}^2)\\I_y = \frac{1}{12}\sum_{i=0}^{n-1} (x_i y_{i+1} - x_{i+1}y_i)(x_i^2 + x_i x_{i+1} + x_{i+1}^2)\end{aligned}\end{align} \]where indices wrap around (n+1 = 1).
The moments are then adjusted to be relative to a reference point using the parallel axis theorem. The moment of inertia is then the sum of \(I_x\) and \(I_y\). In geographic contexts, the reference point is typically the centroid, which is the default if no reference point is provided. However, other points of interest may be used, such as a capital city or the residence of a political representative.
The moment of inertia can be normalized to provide a compactness measure by comparing it with the moment of inertia of a circle of equal area. This is calculated as the ratio of the moment of inertia of the circle to that of the shape about its centroid:
\[C_{MI} = \frac{I_{circle}}{I_{shape}} = \frac{A^2}{2 \pi I_{shape}}\]where \(A\) is the area of the polygon and \(I_{shape}\) is the moment of inertia of the polygon. This formulation is from Li, et al (2013). The value of \(C_{MI}\) is bounded between 0 and 1, with 1 representing a perfect circle, the most compact shape by this measure.
References
[1]Godwin, A. N. 1980. “Simple Calculation of Moments of Inertia for Polygons.” International Journal of Mathematical Education in Science and Technology 11 (4): 577–86. https://doi.org/10.1080/0020739800110414.
[2]Li, Wenwen, Michael F. Goodchild, and Richard Church. 2013. “An Efficient Measure of Compactness for Two-Dimensional Shapes and Its Application in Regionalization Problems.” International Journal of Geographical Information Science 27 (6): 1227–50. https://doi.org/10.1080/13658816.2012.752093.