5/8 Add polygon land-cover apportionment and ingestion - #42
Open
Timothy-W-Hilton wants to merge 4 commits into
Open
5/8 Add polygon land-cover apportionment and ingestion#42Timothy-W-Hilton wants to merge 4 commits into
Timothy-W-Hilton wants to merge 4 commits into
Conversation
added 4 commits
August 15, 2026 15:44
Add a generic utility that intersects classified vector polygons with a regular target grid and records per-class fractional coverage. Require a caller-supplied equal-area CRS for area calculations, preserve the target spatial metadata, and test full and partial cell coverage.
Transform target-cell bounds into the source polygon CRS before querying the GeoPandas spatial index, ensuring candidate polygons are found when the target grid and source data use different CRSs. Add a regression test using geographic target cells and NZTM source polygons to verify correct fractional coverage.
Rasterize an all-touched polygon footprint before exact vector intersections so target cells that cannot overlap any source polygon are skipped. This preserves boundary coverage while avoiding unnecessary geometry work for uncovered cells.
Allow callers with source-class fractions already aligned to the satellite grid to map and aggregate them into VPRM-class fractions without another regridding step. Validate grid coordinates, CRS, fractional bounds, and complete class mappings; add focused tests for aggregation, metadata retention, and unmapped classes.
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.
Add polygon land-cover apportionment and ingestion
Summary
Add a generic path for using polygon-native land-cover products with pyVPRM. The new utility calculates fractional source-class coverage for each cell of an existing regular satellite grid. A companion preprocessor method maps those already-grid-aligned source fractions to VPRM classes without regridding them again.
Existing fractional land-cover workflow
pyVPRM already supports fractional VPRM land cover from a categorical raster:
add_land_cover_map()maps source pixels to VPRM classes, creates a binary layer for each resulting class, and conservatively regrids those layers to the satellite grid.This PR does not replace that workflow. It adds the corresponding input path for products that begin as vector polygons, or for fractions computed by an external geometric workflow.
What this adds
pyVPRM.apportion_polygons_to_grid.apportion().vprm_preprocessor.add_fractional_land_cover_map().Example
Validation
4 passed.