esda.shape.moment_of_inertia_regions

esda.shape.moment_of_inertia_regions(collection, normalize=False, ref_pt=None, regions=None, weights=None)[source]

Compute weighted moment of inertia per region. See Notes for behavior when either regions or weights are omitted.

Parameters:
collectionGeoSeries, GeoDataFrame, numpy.ndarray, list

Input collection of polygons or multipolygons.

normalizebool, optional

If True, returns moment normalized by reference cricle of same area and mass (sum of weights in the region). Default is False.

ref_ptGeoSeries, Shapely Point or list of Points, array_like of shape

(2,) or (n, 2), or dict of any of these, 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 region or geometry. If regions is provided, this must be a dict with one item per region, with the key equal to the region identifier and the value equal to a point geometry or point coordinates. See moment_of_inertia for details.

regionsarray_like, str, optional

An iterable of region identifiers of the same length as collection that each geometry is assigned to, or the name of a column in the GeoDataFrame to use for region assignment. If None (default), moment of inertia is calculated for each geometry in collection without regionalization.

weightsarray_like, optional

An iterable of weights (e.g., population) of the same length as collection that are applied to each geometry in collection, or the name of a column in the GeoDataFrame to use for weights. If None (default), calculates second moment of area using the shoelace formula.

Returns:
pandas.Series or numpy.ndarray

If regions is provided, returns a pandas.Series indexed by unique region IDs, containing moments per region. If regions is omitted, retuns an numpy.ndarray of moments per geometry in collection.

Calculates the mass moment of inertia for regions defined by assignment of
geometries in the collection.
Requires either a column name with region assignments or an array_like of
region IDs. Weights can be provided as a column name or an array-like. If
either regions or weights is a str, collection must be a
GeoDataFrame and the column name must be a valid column in the GeoDataFrame.
If weights are not provided, geometries weighted by area, which is equivalent
to the second moment of area.

Notes

See moment_of_inertia for an introduction. Note that moment of intertia and second moment of area are used interchangeably in some disciplines (see Li, et al 2013). In this discussion “mass moment of inertia” is used to represent a weighted moment of inertia, and “second moment of area” is used for an unweighted moment of inertia. This module’s moment_of_inertia function returns the second moment of area only.

This function extends the moment_of_inertia implementation to allow regionalization and/or weighting. Region identifiers are provided via the regions parameter. Weighting is provided via the weights parameter.

If region identifiers are provided, the geometries in collection are subareas within larger regions defined by the region identifier. The moment of inertia (possibly weighted) is calculated for each region as a whole. If omitted, moments are calculated for each geometry in collection.

If weights are provided, the mass moment of inertia is calculated using a value of interest, such as population, as the mass of the shape. Implementation details vary with whether regions are provided or normalization is requested. This is discussed in detail below. First, if weights are not provided, each geometry is weighted by area, and the result is equivalent to the second moment of area. If weights are provided and normalization is requested, the mass of the shape and the reference circle cancel, and the result is equivalent to the normalized second moment of area.

The mass moment of inertia of a point is equal to its mass times the distance to a reference point squared. For a shape rotating about its centroid the moment of inertia is:

\[I = \sum_{i} m_i r_i^2\]

where \(r_i\) is the distance from the point to a reference point, \(m_i\) is the mass at each point, and there are an infinite number of points filling the shape.

The mass moment of inertia can be calculated for an area of uniform density or an area of varying density. For areas of uniform density, this is the equivalent of the second moment of area times the mass of the shape divided by the area. If regions is not provided, the mass moment of inertia is calculated for each geometry in collection as an area of uniform density. This is implemented as:

\[I_M = I_A m / A\]

where \(I_A\) is the second moment of area (calculated by moment_of_inertia) and \(m\) and \(A\) are the mass and area of the shape, respectively.

For a region of varying density, region identifiers must be provided via the regions parameter. \(I_M\) is calculated for each geometry in collection per the equation above, with each geometry representing a subarea of the region with mass given by weights. The mass moment of inertia of the region is then the sum of the mass moments of inertia of each subarea shifted to the reference point (using the parallel axis theorem) by adding \(m d^2\), where \(d\) is the distance from the centroid of each subarea to the reference point for the region.

If reference points are not provided, the mass moment of inertia is calculated with respect to the centroid of each region (calculated by the algorithm). If provided, ref_pt may be a single point about which the mass moment of inertia is calculated for all regions, or it may be a dict with one item per region indicating the reference point (value) to use for that region (key). If any region identifier does not appear as a dict key, an error is raise. Extra keys in the dict that do not correspond to any region identifiers are ignored with a warning.

The mass moment of inertia can be normalized to provide a compactness measure using the formula from Fan, et al. (2015):

\[C_{NMMI} = \frac{M A}{2 \pi I_M}\]

where \(I_M\) is the mass moment of inertia of the shape. This represents the ratio of the mass moment of inertia of a circle with the same area and mass as the shape to the mass moment of inertia of the shape. In this case, the measure can exceed 1, as will happen when mass is concentrated near the centroid of the shape. This can be interpreted as a more compact distribution than a uniform circle.

References

[1]

Weaver, James B., and Sidney W. Hess. 1963. “A Procedure for Nonpartisan Districting: Development of Computer Techniques.” Yale Law Journal 73 (2): 288–308. https://doi.org/10.2307/794769

[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.

[3]

Fan, Chao, Wenwen Li, Levi J. Wolf and Soe W. Myint. 2015 “A Spatiotemporal Compactness Pattern Analysis of Congressional Districts to Assess Partisan Gerrymandering: A Case Study with California and North Carolina.” Annals of the Association of American Geographers 105 (4): 736-753. https://doi.org/10.1080/00045608.2015.1039109