Landslide Science Rule · polygon_volume
← All rules

polygon_volume → writes polygon_volume

1901 already match 0 would change

Function source

This is read live from inventory/derived.py via inspect.getsource(); what you see is exactly what runs.

def compute_polygon_volume():
    """Per-polygon estimated volume (m³).

    Branches on parent landslide + polygon role:
      - "Creeping permafrost mass" in features →  PERMAFROST_THICKNESS_M × area
                                           (uniform thickness regardless of role)
      - landslide_type='slow', role='body'           →  0.1 × area^1.5
      - landslide_type='catastrophic', role='source' →  0.1 × area^1.5
      - landslide_type='catastrophic', role='deposit' →  CAT_DEPOSIT_THICKNESS_M
                                                          × area
      - anything else                                →  NULL

    Multi-source catastrophic landslides get each source polygon estimated
    independently; the per-role SUMs are taken in the volume_source/deposit
    rules below.
    """
    return f"""
        SELECT p.id,
               CASE
                 WHEN {feature_sql('Creeping permafrost mass')} THEN
                   ROUND(20 * p.area)::bigint
                 WHEN l.landslide_type = 'slow' AND p.role = 'body' THEN
                   ROUND(0.1 * POWER(p.area, 1.5))::bigint
                 WHEN l.landslide_type = 'catastrophic' AND p.role = 'source' THEN
                   ROUND(0.1 * POWER(p.area, 1.5))::bigint
                 WHEN l.landslide_type = 'catastrophic' AND p.role = 'deposit' THEN
                   ROUND(2 * p.area)::bigint
                 ELSE NULL
               END AS computed
        FROM landslide_polygons p
        JOIN landslides l ON l.id = p.landslide_id
        ORDER BY p.id
    """

Proposed changes

All rows already match this rule — nothing to apply.