quickpaver.compute_transfer_matrix#

quickpaver.compute_transfer_matrix(source_grid: MultiPolygon, target_grid: MultiPolygon, is_sanity_check: bool = False) csc_array[source]#

Build a conservative transfer matrix between two polygonal grids.

The resulting sparse matrix distributes values defined on the source grid onto the target grid using surface intersection prorata weights.

The matrix coefficients are defined as:

:contentReference[oaicite:0]{index=0}

where:

  • \(S_i\) is the i-th source polygon

  • \(T_j\) is the j-th target polygon

Therefore:

\[\sum_j W_{ij} = 1\]

for every source polygon fully covered by the target grid.

Parameters:
  • source_grid (shapely.MultiPolygon) – Source polygon grid.

  • target_grid (shapely.MultiPolygon) – Target polygon grid.

  • is_sanity_check (bool) – Whether to perform a sanity check at the end of the transfer. The default is False.

Returns:

Sparse conservative transfer matrix of shape:

\[(n_{source}, n_{target})\]

such that:

\[v_{target} = W^T v_{source}\]

Return type:

scipy.sparse.csc_array

Notes

The implementation uses:

  • STRtree spatial indexing

  • vectorized Shapely intersection operations

  • sparse COO matrix assembly