Fix to calculation of normalized mass moment of inertia (in moment_of_inertia_regions function) - #438
Merged
Merged
Conversation
…e adjusted for m (population) and A (area) of subgeom
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #438 +/- ##
=====================================
Coverage 82.2% 82.2%
=====================================
Files 27 27
Lines 3969 3969
=====================================
Hits 3264 3264
Misses 705 705
🚀 New features to boost your workflow:
|
…sal#437; MMI is no longer calculated using the discrete approximation
Member
|
One thing to note - the PR titles are automatically pulled to the release notes to form a changelog. I'd suggest to make them a bit more suited for the purpose :). |
moment_of_inertia_regions function)
Contributor
Author
Acknowledged and changed. |
ljwolf
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for #437 .
Normalized mass moment of inertia is calculated with:
moment_of_inertia_regions(geometry_array, normalize=True, regions=<geom region assignment>, weights=<geom weight>)Error was discovered in that the moment of inertia calculated for each geometry in the region was not adjusted for its mass (weight) and area. Depending upon the CRS, the area adjustment could be large. The mass moment of inertia for the reference circle was calculated correctly, because the formula is very straightforward ($mA/2\pi$ ).
The NMMI is the MMI of the reference circle divided by the (nonnormalized) MMI of the region. The following is a general strategy for confirming the expected NMMI with any input geometry.
Assume a geodataframe
gdfwith region assignments in the column"region"and weights in the column"mass".When executed on the virginia counties built-in dataset with counties grouped by Virginia economic regions, the manually calculated NMMI was 0.3% smaller than the NMMI calculated by the function.