Four ways a selection produced a confident number about a different area than the operator drew: Flood hazard divided the inundated cells by every cell in the drawn rectangle, including cells the VMM raster does not model at all. A selection reaching past the modelled extent therefore reported a diluted risk share, turning missing data into an implied absence of risk. Terrain, bathymetry and thematic raster already divided by valid cells; flood hazard was the outlier. It now reports the three populations separately, states model coverage next to the drawn area, and returns a null fraction rather than a zero when nothing was modelled. geometry_mask selects a cell when its centre falls inside the geometry, so a rectangle smaller than one cell — or one landing between four centres — selected nothing and the analysis returned zeros indistinguishable on screen from "we looked and there is nothing here". On a 100 m population raster a 40 m rectangle over a city block reported no inhabitants. Selection now falls back to the touched cells and says that it did, since the answer then covers more ground than was requested. rasterio.mask applies the same centre rule when cropping, so that call is widened too; the cells that count are still decided by the centre rule wherever it selects anything. The object count treated any feature touching the selection as whole, while intersection_area clipped it — two headline numbers on one panel describing different populations. The count stays whole-feature, which is what "objecten" means to an operator, but now reports how many the edge cuts and is marked an estimate when it does. The area_weighted_sum branch reuses that same count instead of issuing its own near-identical query. Partitioned selection de-duplicated the count on source_feature_id but returned the raw rows, so a building on a municipal boundary was counted once and drawn twice. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
126 lines
3.0 KiB
Python
126 lines
3.0 KiB
Python
from __future__ import annotations
|
|
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from .operations import VectorSelectionBBox
|
|
|
|
|
|
class ThematicRasterAcquireRequest(BaseModel):
|
|
bbox: VectorSelectionBBox
|
|
area_id: UUID | None = None
|
|
product_key: str
|
|
force_refresh: bool = False
|
|
|
|
|
|
class ThematicRasterProductRead(BaseModel):
|
|
key: str
|
|
display_name: str
|
|
theme: str
|
|
metric_kind: str
|
|
coverage_id: str
|
|
native_resolution_m: float
|
|
source_crs: str
|
|
source_value_unit: str
|
|
observation_year: int
|
|
source_version: str
|
|
catalog_url: str
|
|
attribution: str
|
|
license_note: str
|
|
legend_min_label: str
|
|
legend_max_label: str
|
|
included_source_values: list[int]
|
|
limitation_message: str
|
|
analysis_resolution_m: float | None = None
|
|
coverage_zones: list[str] = Field(default_factory=list)
|
|
configured: bool = True
|
|
status: str = "configured"
|
|
|
|
|
|
class WalousAcquisitionResult(BaseModel):
|
|
output_dataset_id: UUID
|
|
reused: bool
|
|
provider: str
|
|
product_key: str
|
|
display_name: str
|
|
theme: str
|
|
metric_kind: str
|
|
resolution_m: float
|
|
width: int
|
|
height: int
|
|
valid_pixel_count: int
|
|
bbox_epsg4326: list[float]
|
|
bbox_epsg3812: list[float]
|
|
observation_year: int
|
|
source_value_unit: str
|
|
attribution: str
|
|
limitation_message: str
|
|
|
|
|
|
class ThematicRasterAcquisitionResult(BaseModel):
|
|
output_dataset_id: UUID
|
|
reused: bool
|
|
provider: str
|
|
product_key: str
|
|
display_name: str
|
|
theme: str
|
|
metric_kind: str
|
|
coverage_id: str
|
|
resolution_m: float
|
|
width: int
|
|
height: int
|
|
valid_pixel_count: int
|
|
bbox_epsg4326: list[float]
|
|
bbox_epsg31370: list[float]
|
|
observation_year: int
|
|
source_value_unit: str
|
|
attribution: str
|
|
limitation_message: str
|
|
|
|
|
|
class ThematicRasterSelectionRequest(BaseModel):
|
|
bbox: VectorSelectionBBox
|
|
area_id: UUID | None = None
|
|
|
|
|
|
class ThematicRasterMetric(BaseModel):
|
|
metric_key: str
|
|
metric_label: str
|
|
metric_value: float
|
|
metric_unit: str
|
|
aggregation_method: str
|
|
derived: bool = True
|
|
is_estimate: bool = True
|
|
|
|
|
|
class ThematicRasterSelectionSummary(BaseModel):
|
|
metric_label: str
|
|
metric_value: float
|
|
metric_unit: str
|
|
aggregation_method: str
|
|
primary_metric_key: str
|
|
metrics: list[ThematicRasterMetric]
|
|
|
|
|
|
class ThematicRasterSelectionResponse(BaseModel):
|
|
dataset_id: UUID
|
|
product_key: str
|
|
theme: str
|
|
metric_kind: str
|
|
selection_bbox: VectorSelectionBBox
|
|
selection_area_id: UUID | None = None
|
|
selected_cell_count: int
|
|
valid_cell_count: int
|
|
coverage_ratio: float
|
|
# Set when the drawn selection is smaller than one source cell and the
|
|
# analysis was widened to the cells it touches, so the value covers more
|
|
# ground than was requested.
|
|
cell_selection_warning: str | None = None
|
|
resolution_m: float
|
|
observation_year: int
|
|
summary: ThematicRasterSelectionSummary
|
|
unsupported_metrics: list[str]
|
|
limitation_message: str
|
|
generated_at: str
|