xrspatial.dasymetric.validate_disaggregation#
- xrspatial.dasymetric.validate_disaggregation(result: DataArray, zones: DataArray, values: dict | Series, tolerance: float = 1e-06) bool[source]#
Check that zone totals in result match values within tolerance.
- Parameters:
result (xr.DataArray) – Output of
disaggregate()orpycnophylactic().zones (xr.DataArray) – The zone raster used to produce result.
values (dict or pd.Series) – The original
zone_id -> valuemapping.tolerance (float, default 1e-6) – Maximum allowed relative error per zone. Zones whose total weight is zero (result all NaN) are skipped.
- Returns:
Trueif all zone totals are within tolerance.- Return type:
bool
- Raises:
ValueError – If any zone total exceeds the tolerance, with details on which zones failed.
Examples
>>> from xrspatial.dasymetric import disaggregate, validate_disaggregation >>> result = disaggregate(zones, values, weight) >>> validate_disaggregation(result, zones, values) True