Skip to main content

Chapter 11: Basis risk: payouts against reported damage

Chapter 11: Basis risk: payouts against reported damage

TipAt a glance
  • You will build: the views out.basis_risk (payout and reported damage per insured unit, season and crop year) and out.basis_risk_summary (the 2x2 table of payouts and losses, for Java and each province)
  • You need: Chapters 3 to 10; PostgreSQL 17 or later
  • Time to run: Under a minute (the checkpoint prints the time)
  • Level: Intermediate

An index contract pays on rainfall, not on the harvest. Basis risk is the gap between the two (Chapter 1, section 3): a loss in the fields without a payout, or a payout without a loss. This chapter measures that gap for the contract of Chapter 9. It sets every unit-season against the drought damage that the Ministry of Agriculture reported for it (Chapter 3), counts the four outcomes of a 2x2 table, puts intervals on the rates, asks how well the index ranks the damage at all, and looks at the provisional crop year on its own. It ends with an exercise on flood, reported over a larger area than drought, which the rainfall index does not see. Payouts and rates remain illustrative, and the damage they are measured against is reported, not measured.

NoteLearning objectives

By the end of this chapter you will be able to:

  • match monthly reports to seasons with daterange and the operators <@;
  • build a 2x2 table and its rates in one query, for the whole and for each group, with GROUPING SETS;
  • check a data rule (crop failure never above affected area) before relying on it, and list its exceptions with lag();
  • put bootstrap intervals on rates and score the index against damage with the AUC, pooled and within a year;
  • compute a five-day rainfall maximum with a ROWS window frame.

Before running this chapter:

  • complete Chapters 3 to 10; Chapter 3 loads the damage reports raw.datanonkom_damage;
  • use PostgreSQL 17 or later: the bootstrap of section 7 uses random(min, max), added in version 17;
  • allow under a minute for the whole chapter. No downloads are needed. The views are replaced on every run.

1. Setup

The setup cell reads config.yml, defines connect() and ENGINE as in the earlier chapters, and checks the tables of the earlier chapters, including both rows of idx.data_status that the views rely on. UNIT is the unit looked at closely (Garut, as before); FLOOD_UNIT is the unit of the flood exercise (Pati, in Jawa Tengah, which section 10 shows to report flood often); SEED and REPLICATES are the settings of the bootstrap in section 7, as in Chapter 10.

import os
os.environ.setdefault("MKL_THREADING_LAYER", "SEQUENTIAL")   # before numpy is imported (ledger L128)

import datetime as dt
import time
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import psycopg
import yaml
from psycopg import sql
from sqlalchemy import URL, create_engine

T0 = time.perf_counter()
UNIT = "3205"                     # BPS code of Kabupaten Garut
FLOOD_UNIT = "3318"               # BPS code of Kabupaten Pati (section 10)
REPLICATES = 2000                 # bootstrap replicates (section 7)
SEED = 0.20261201                 # setseed() value, as in Chapter 10

ROOT = Path.cwd() if (Path.cwd() / "tutorial.yml").exists() else Path.cwd().parent
CONFIG = yaml.safe_load((ROOT / "config.yml").read_text(encoding="utf-8"))
DB = CONFIG["database"]


def connect(**kwargs):
    """A new session in the tutorial database (Chapter 2)."""
    return psycopg.connect(**DB, **kwargs)


ENGINE = create_engine(URL.create("postgresql+psycopg", username=DB["user"], host=DB["host"],
                                  port=DB["port"], database=DB["dbname"]))

with connect() as conn:
    print("connected |", conn.execute("SELECT postgis_full_version()").fetchone()[0][:60], "...")
    for table in ["raw.datanonkom_damage", "raw.chirps_rnl_daily", "ref.province", "idx.insured_unit",
                  "idx.paddy_weight", "idx.chirps_dekad", "idx.season_dekad", "idx.data_status", "out.payout"]:
        if not conn.execute("SELECT to_regclass(%s)", [table]).fetchone()[0]:
            raise RuntimeError(f"{table} is missing: run Chapters 3 to 10 first")
    sources = {r[0] for r in conn.execute("SELECT source FROM idx.data_status")}
    if not {"chirps_rnl", "datanonkom_dpi"} <= sources:
        raise RuntimeError(f"idx.data_status needs rows chirps_rnl and datanonkom_dpi (Chapter 4), has {sources}")
    unit_name = conn.execute("SELECT name FROM idx.insured_unit WHERE code = %s", [UNIT]).fetchone()[0]
    flood_name = conn.execute("SELECT name FROM idx.insured_unit WHERE code = %s", [FLOOD_UNIT]).fetchone()[0]
    status = pd.DataFrame(conn.execute("SELECT source, first_day, available_through, final_through "
                                       "FROM idx.data_status ORDER BY source").fetchall(),
                          columns=["source", "first_day", "available_through", "final_through"])
print(f"unit looked at: {UNIT} {unit_name} | flood exercise: {FLOOD_UNIT} {flood_name}")
status
connected | POSTGIS="3.7.0 3.7.0" [EXTENSION] PGSQL="180" GEOS="3.15.1-C ...
unit looked at: 3205 Garut | flood exercise: 3318 Pati
source first_day available_through final_through
0 chirps_rnl 1981-01-01 2026-09-30 2025-09-30
1 datanonkom_dpi 2016-01-01 2026-11-30 2025-12-31

2. What counts as a loss

The damage reports of Chapter 3 give, per kabupaten/kota and month, the rice area reported as hit by drought or flood in two classes: terkena (affected) and puso (crop failure). Field officers collect them every month, the Ministry of Agriculture compiles them and publishes them on the datanonkom portal (ledger L172). They are reported areas, not measurements, and a value of 0.00 can also mean a month not yet reported (ledger L19). The regulation that is the likely primary source for these reports was not read for this series, so whether it defines the two classes is unknown (ledger L113); the data behave as if puso were part of terkena (section 5).

The series counts a unit-season as a loss when the drought terkena reported over the season exceeds 1% of the unit’s paddy. Two choices sit in that sentence:

  • the damage window: the months the season grows in, plus one month, in case damage is reported late;
  • the threshold: terkena, not puso, above 1% of the paddy area.

Other choices move the results by different amounts. Over the windows tried, the share of losses paid stays between 0.27 and 0.30; over the thresholds tried, it stays between 0.20 and 0.37, but the share of payouts without a loss runs from 0.14 to 0.72 (ledger L82, ledger L83). Read that second rate as depending on the 1% choice. Both window families were shaped after seeing when damage is reported (ledger L83), as the MK1 planting date was (Chapter 7).

The damage record runs from January 2016 (the data status above), so only the seasons whose window lies wholly inside it can be scored: for MK1 the crop years 2015 to 2024 (the MK1 of crop year 2015 is planted in 2016), ten seasons per unit, plus the provisional 2025.

3. Damage per unit and month

The reports are a long table: one row per unit, topic, variable, year, month and class. Topic 3 holds the damage from climate impacts (dampak perubahan iklim, DPI, Chapter 3): variable 11 is Kekeringan Padi (rice drought), 8 is Banjir Padi (rice flood); class 2 is terkena, 3 is puso; month 13 is the yearly total (Setahun), left out here. As in Chapter 3, sum(ha) FILTER (WHERE ...) turns the four combinations needed into four columns. The cell shows UNIT in 2019, a year of large reported drought damage (Chapter 3).

DAMAGE_MONTH = """
SELECT code::text AS kabupaten_code, make_date(year, month, 1) AS month_start,
       sum(ha) FILTER (WHERE variabel_id = 11 AND klasifikasi_id = 2) AS drought_terkena,
       sum(ha) FILTER (WHERE variabel_id = 11 AND klasifikasi_id = 3) AS drought_puso,
       sum(ha) FILTER (WHERE variabel_id = 8 AND klasifikasi_id = 2)  AS flood_terkena,
       sum(ha) FILTER (WHERE variabel_id = 8 AND klasifikasi_id = 3)  AS flood_puso
FROM raw.datanonkom_damage
WHERE topik = 3 AND variabel_id IN (8, 11) AND month BETWEEN 1 AND 12
GROUP BY 1, 2"""
pd.read_sql(f"SELECT * FROM ({DAMAGE_MONTH}) d WHERE kabupaten_code = %(u)s AND month_start >= '2019-01-01' "
            "AND month_start < '2020-01-01' ORDER BY month_start", ENGINE, params={"u": UNIT})
kabupaten_code month_start drought_terkena drought_puso flood_terkena flood_puso
0 3205 2019-01-01 0.0 0.0 21.0 7.0
1 3205 2019-02-01 64.0 0.0 3.0 3.0
2 3205 2019-03-01 0.0 0.0 2.0 2.0
3 3205 2019-04-01 0.0 0.0 0.0 0.0
4 3205 2019-05-01 0.0 0.0 0.0 0.0
5 3205 2019-06-01 1089.0 1089.0 0.0 0.0
6 3205 2019-07-01 1244.0 271.0 0.0 0.0
7 3205 2019-08-01 470.0 371.0 0.0 0.0
8 3205 2019-09-01 131.0 101.0 0.0 0.0
9 3205 2019-10-01 206.0 148.0 0.0 0.0
10 3205 2019-11-01 228.0 36.0 0.0 0.0
11 3205 2019-12-01 0.0 0.0 0.0 0.0

Look before moving on. Most of the drought damage should fall in the dry months, here June to November (a small drought report in a wet month can occur), the flood damage in the wet months, and puso should not exceed terkena in a month. The query text is reused below as a CTE; pasting a fixed query of this notebook into another with an f-string is safe, as in Chapter 7.

4. Damage windows as date ranges

Each season of idx.season_dekad (Chapter 7) gets a window of months: from the first day of the month of its first dekad to the end of the month after its last dekad. The reports are monthly, so a window starts on the 1st of the transplanting month, and the windows of two seasons can share a month: in 434 unit crop years the extra month of the MH window overlaps the start of MK1, though no MK1 loss depends on it (ledger L171). daterange(a, b) stores the window as a half-open range [a, b), so the upper bound is the first day of the second month after the last dekad, and upper(w) - 1 is the window’s last day. Two operators do the matching:

  • month_start <@ damage_window: is the month inside the window?
  • damage_window <@ daterange(first_day, available_through, '[]'): does the whole window lie inside the damage record? '[]' makes both ends inclusive.

date_trunc('month', x::timestamp) gives the first moment of the month; the cast to timestamp keeps the time zone of the session out of it. The cell shows the windows of UNIT for crop year 2018, with the transplanting date.

SEASON_WINDOW = """
SELECT kabupaten_code, season, crop_year,
       daterange(date_trunc('month', min(dekad_start)::timestamp)::date,
                 (date_trunc('month', max(dekad_start)::timestamp) + interval '2 months')::date) AS damage_window
FROM idx.season_dekad
GROUP BY kabupaten_code, season, crop_year"""
pd.read_sql(f"""SELECT w.season, w.crop_year, w.damage_window::text AS damage_window,
                       (SELECT min(dekad_start) FROM idx.season_dekad s WHERE s.kabupaten_code = w.kabupaten_code
                          AND s.season = w.season AND s.crop_year = w.crop_year) AS transplanting
                FROM ({SEASON_WINDOW}) w
                WHERE w.kabupaten_code = %(u)s AND w.crop_year = 2018 ORDER BY w.season""", ENGINE, params={"u": UNIT})
season crop_year damage_window transplanting
0 MH 2018 [2018-11-01,2019-04-01) 2018-11-11
1 MK1 2018 [2019-05-01,2019-10-01) 2019-05-21

Look before moving on. The MK1 of crop year 2018 grew in 2019; its window should start on the 1st of its transplanting month and end one month after its last dekad.

5. One row per unit-season: the view out.basis_risk

The view joins the payouts of Chapter 9 to the windows and sums the monthly damage inside each window. The two single-row subqueries of idx.data_status, joined with CROSS JOIN, attach the final dates to every row. A LEFT JOIN keeps unit-seasons with no damage row at all; coalesce(..., 0) turns their sums into 0. Besides the damage it records:

  • provisional: the season’s rain is not final (idx.data_status, as in Chapter 10), or its window reaches past the date to which the damage reports are taken as final;
  • positive_months: window months with any positive rice drought or flood report (0 means the unit reported no rice drought or flood damage at all in the window);
  • puso_gt_terkena_months: window months where puso exceeds terkena;
  • loss_event (drought terkena above 1% of paddy) and paid (a payout above 0).

It is a view, so it follows idx.data_status and the payouts without being rebuilt.

BASIS_RISK = f"""
CREATE OR REPLACE VIEW out.basis_risk AS
WITH damage_month AS ({DAMAGE_MONTH}),
season_window AS ({SEASON_WINDOW})
SELECT p.kabupaten_code, p.season, p.crop_year, p.season_label,
       w.damage_window,
       (p.season_end > rain.final_through OR upper(w.damage_window) - 1 > dpi.final_through) AS provisional,
       u.paddy_ha::double precision AS paddy_ha,
       p.index_value, p.payout_frac, p.payout_ha_eq,
       p.payout_frac > 0 AS paid,
       coalesce(sum(d.drought_terkena), 0)::double precision AS drought_terkena_ha,
       coalesce(sum(d.drought_puso), 0)::double precision    AS drought_puso_ha,
       coalesce(sum(d.flood_terkena), 0)::double precision   AS flood_terkena_ha,
       coalesce(sum(d.flood_puso), 0)::double precision      AS flood_puso_ha,
       count(*) FILTER (WHERE greatest(d.drought_terkena, d.drought_puso, d.flood_terkena, d.flood_puso) > 0)
           AS positive_months,
       count(*) FILTER (WHERE coalesce(d.drought_puso, 0) > coalesce(d.drought_terkena, 0)
                           OR coalesce(d.flood_puso, 0) > coalesce(d.flood_terkena, 0)) AS puso_gt_terkena_months,
       coalesce(sum(d.drought_terkena), 0) > 0.01 * u.paddy_ha AS loss_event
FROM out.payout p
JOIN idx.insured_unit u ON u.code = p.kabupaten_code
JOIN season_window w USING (kabupaten_code, season, crop_year)
CROSS JOIN (SELECT first_day, available_through, final_through FROM idx.data_status
            WHERE source = 'datanonkom_dpi') dpi
CROSS JOIN (SELECT final_through FROM idx.data_status WHERE source = 'chirps_rnl') rain
LEFT JOIN damage_month d
       ON d.kabupaten_code = p.kabupaten_code
      AND d.month_start <@ w.damage_window
WHERE w.damage_window <@ daterange(dpi.first_day, dpi.available_through, '[]')
GROUP BY p.kabupaten_code, p.season, p.crop_year, p.season_label, w.damage_window, u.paddy_ha,
         p.index_value, p.payout_frac, p.payout_ha_eq, p.season_end, rain.final_through, dpi.final_through"""

with connect() as conn:
    conn.execute(BASIS_RISK)
    conn.execute("COMMENT ON VIEW out.basis_risk IS 'Basis risk: payout per insured unit, season and crop year against "
                 "datanonkom rice damage over the season months + 1 month; loss_event = drought terkena above 1% of "
                 "paddy_ha; provisional from idx.data_status; Chapter 11'")
overview = pd.read_sql("""SELECT season, provisional, count(*) AS unit_seasons, min(crop_year) AS first,
                                 max(crop_year) AS last, count(*) FILTER (WHERE loss_event) AS losses,
                                 count(*) FILTER (WHERE paid) AS payouts,
                                 count(*) FILTER (WHERE positive_months = 0) AS silent_windows
                          FROM out.basis_risk GROUP BY 1, 2 ORDER BY 1, 2""", ENGINE)
overview
season provisional unit_seasons first last losses payouts silent_windows
0 MH False 895 2015 2024 11 95 184
1 MH True 99 2025 2025 1 16 26
2 MK1 False 990 2015 2024 226 97 302
3 MK1 True 99 2025 2025 21 40 24

Look before moving on. MK1 should have ten final crop years per unit and the provisional 2025; MH starts a crop year later for most units, because the window of the MH of crop year 2015 begins before January 2016. silent_windows counts unit-seasons in which the unit reported no rice drought or flood damage at all: either nothing happened, or nothing was reported, which the data cannot tell apart (ledger L19, ledger L93).

A rule to check before relying on it

If puso is part of terkena, a window’s puso can never exceed its terkena. The series keeps the damage values as published and lets the build check the rule (ledger L114): the first query counts windows where the summed puso exceeds the summed terkena (it must be 0), the second lists the single months where puso exceeds terkena in the insured units, next to the month before. lag(x) OVER w returns the value of the previous row in the partition and order of the window w. The filter puso > terkena sits outside the CTE that computes lag: a filter inside it would make lag see only the flagged months.

PUSO_LISTING = """
WITH pair AS (
    SELECT d.code::text AS code, d.variabel, d.year, d.month,
           sum(d.ha) FILTER (WHERE d.klasifikasi_id = 2) AS terkena,
           sum(d.ha) FILTER (WHERE d.klasifikasi_id = 3) AS puso
    FROM raw.datanonkom_damage d
    JOIN idx.insured_unit u ON u.code = d.code
    WHERE d.topik = 3 AND d.variabel_id IN (8, 11) AND d.month BETWEEN 1 AND 12
    GROUP BY d.code, d.variabel, d.year, d.month
),
with_prev AS (
    SELECT pair.*, lag(terkena) OVER w AS terkena_month_before, lag(puso) OVER w AS puso_month_before
    FROM pair
    WINDOW w AS (PARTITION BY code, variabel ORDER BY year, month)
)
SELECT p.code, u.name, p.variabel, make_date(p.year, p.month, 1) AS month, p.terkena, p.puso,
       p.terkena_month_before, p.puso_month_before
FROM with_prev p JOIN idx.insured_unit u ON u.code = p.code
WHERE p.puso > p.terkena
ORDER BY p.code, p.year, p.month"""
with connect() as conn:
    bad = conn.execute("""SELECT count(*) FROM out.basis_risk
                          WHERE drought_puso_ha > drought_terkena_ha OR flood_puso_ha > flood_terkena_ha""").fetchone()[0]
    flagged = conn.execute("SELECT count(*) FROM out.basis_risk WHERE puso_gt_terkena_months > 0").fetchone()[0]
if bad:
    raise RuntimeError(f"{bad} windows with summed puso above summed terkena: decide how to treat them first (ledger L114)")
print(f"windows with summed puso above summed terkena: {bad}; scored windows with a month of puso above terkena: {flagged}")
pd.read_sql(PUSO_LISTING, ENGINE)
windows with summed puso above summed terkena: 0; scored windows with a month of puso above terkena: 2
code name variabel month terkena puso terkena_month_before puso_month_before
0 3306 Purworejo Kekeringan Padi 2024-09-01 0.6 1.0 20.06 4.96
1 3323 Temanggung Kekeringan Padi 2024-08-01 0.8 1.2 2.00 0.80
2 3324 Kendal Kekeringan Padi 2024-08-01 1.0 5.0 21.00 8.00

Look before moving on. No window breaks the rule. Each of the few months that do follows a month with more terkena than puso: the failure was probably reported a month after the damage. Of the months listed, the scored windows contain fewer than all: a month can fall between the windows of two seasons (ledger L114). Chapter 3 found more such months across all crops and pests; only rice drought and flood count here (ledger L107). Their effect on the results below is nil (ledger L110). If a later refresh broke the rule at window level, the cell would stop, and the fallback is to cap puso at terkena month by month.

6. The 2x2 table

Each unit-season falls in one of four cells:

loss no loss
paid hit false alarm (a payout without a loss)
not paid miss (a loss without a payout) quiet

The summary view counts them over the final unit-seasons and turns them into rates:

  • p_paid_given_loss, avg(paid::int) FILTER (WHERE loss_event): the share of losses that were paid; one minus it is the share left unpaid, the failure the insured feel most (Chapter 1, section 3);
  • p_noloss_given_paid: the share of payouts that went to unit-seasons without a loss;
  • p_paid_given_noloss: how often the contract paid where no loss was reported;
  • payout_share_to_loss: the share of payout hectare-equivalents (payout share times paddy hectares, Chapter 9) that went to loss unit-seasons;
  • damage_share_paid: the share of the reported drought area that lies in paid unit-seasons;
  • max_p_paid_given_loss, the ceiling: payouts divided by losses, capped at 1. If every payout landed on a loss, the share of losses paid could still be no higher than this.

GROUP BY GROUPING SETS ((season), (season, province)) works like ROLLUP in Chapter 5, with the groups listed explicitly: one row per season for Java and one per season and province, in one query. grouping(x) is 1 on the rows where x was rolled up, which the query labels 'Java'; min(pr.name) picks the one province name of each group. The province is the first two digits of the BPS code. A rate whose group has no rows to divide by stays NULL, and the ceiling is NULL where there are no losses.

SUMMARY = """
CREATE OR REPLACE VIEW out.basis_risk_summary AS
SELECT b.season,
       CASE WHEN grouping(left(b.kabupaten_code, 2)) = 1 THEN 'Java' ELSE left(b.kabupaten_code, 2) END AS province_code,
       CASE WHEN grouping(left(b.kabupaten_code, 2)) = 1 THEN 'Java' ELSE min(pr.name) END AS province,
       min(b.crop_year) AS first_crop_year, max(b.crop_year) AS last_crop_year,
       count(*) AS n,
       count(*) FILTER (WHERE b.loss_event) AS losses,
       count(*) FILTER (WHERE b.paid) AS payouts,
       count(DISTINCT b.crop_year) FILTER (WHERE b.paid) AS payout_years,
       count(*) FILTER (WHERE b.paid AND b.loss_event)         AS hits,
       count(*) FILTER (WHERE NOT b.paid AND b.loss_event)     AS misses,
       count(*) FILTER (WHERE b.paid AND NOT b.loss_event)     AS false_alarms,
       count(*) FILTER (WHERE NOT b.paid AND NOT b.loss_event) AS quiet,
       avg(b.paid::int) FILTER (WHERE b.loss_event)            AS p_paid_given_loss,
       avg((NOT b.loss_event)::int) FILTER (WHERE b.paid)      AS p_noloss_given_paid,
       avg(b.paid::int) FILTER (WHERE NOT b.loss_event)        AS p_paid_given_noloss,
       coalesce(sum(b.payout_ha_eq) FILTER (WHERE b.loss_event), 0) / nullif(sum(b.payout_ha_eq), 0) AS payout_share_to_loss,
       coalesce(sum(b.drought_terkena_ha) FILTER (WHERE b.paid), 0) / nullif(sum(b.drought_terkena_ha), 0) AS damage_share_paid,
       CASE WHEN count(*) FILTER (WHERE b.loss_event) > 0
            THEN least(count(*) FILTER (WHERE b.paid)::double precision / count(*) FILTER (WHERE b.loss_event), 1)
       END AS max_p_paid_given_loss
FROM out.basis_risk b
LEFT JOIN ref.province pr ON pr.code = left(b.kabupaten_code, 2)
WHERE NOT b.provisional
GROUP BY GROUPING SETS ((b.season), (b.season, left(b.kabupaten_code, 2)))"""

with connect() as conn:
    conn.execute(SUMMARY)
    conn.execute("COMMENT ON VIEW out.basis_risk_summary IS 'Basis risk: 2x2 table and rates per season, Java and "
                 "province, final unit-seasons only; Chapter 11'")
summary = pd.read_sql("""SELECT * FROM out.basis_risk_summary
                         ORDER BY season DESC, province_code <> 'Java', province_code""", ENGINE)
silent_fa = pd.read_sql("""SELECT season, count(*) FILTER (WHERE paid AND NOT loss_event) AS false_alarms,
                                  count(*) FILTER (WHERE paid AND NOT loss_event AND positive_months = 0) AS in_silent_windows
                           FROM out.basis_risk WHERE NOT provisional GROUP BY season ORDER BY season DESC""", ENGINE)
print(silent_fa.to_string(index=False))
summary[["season", "province", "first_crop_year", "last_crop_year", "n", "losses", "payouts", "payout_years", "hits",
         "misses", "false_alarms", "quiet", "p_paid_given_loss", "p_noloss_given_paid", "p_paid_given_noloss",
         "payout_share_to_loss", "damage_share_paid", "max_p_paid_given_loss"]].round(3)
season  false_alarms  in_silent_windows
   MK1            35                  8
    MH            89                 25
season province first_crop_year last_crop_year n losses payouts payout_years hits misses false_alarms quiet p_paid_given_loss p_noloss_given_paid p_paid_given_noloss payout_share_to_loss damage_share_paid max_p_paid_given_loss
0 MK1 Java 2015 2024 990 226 97 3 62 164 35 729 0.274 0.361 0.046 0.794 0.268 0.429
1 MK1 Jawa Barat 2015 2024 220 93 33 2 25 68 8 119 0.269 0.242 0.063 0.812 0.391 0.355
2 MK1 Jawa Tengah 2015 2024 310 72 34 3 21 51 13 225 0.292 0.382 0.055 0.816 0.188 0.472
3 MK1 Daerah Istimewa Yogyakarta 2015 2024 40 5 3 1 3 2 0 35 0.600 0.000 0.000 1.000 0.756 0.600
4 MK1 Jawa Timur 2015 2024 350 35 18 2 6 29 12 303 0.171 0.667 0.038 0.551 0.075 0.514
5 MK1 Banten 2015 2024 70 21 9 2 7 14 2 47 0.333 0.222 0.041 0.984 0.541 0.429
6 MH Java 2015 2024 895 11 95 10 6 5 89 795 0.545 0.937 0.101 0.101 0.460 1.000
7 MH Jawa Barat 2016 2024 198 1 25 6 0 1 25 172 0.000 1.000 0.127 0.000 0.128 1.000
8 MH Jawa Tengah 2016 2024 279 4 30 2 4 0 26 249 1.000 0.867 0.095 0.249 0.827 1.000
9 MH Daerah Istimewa Yogyakarta 2016 2024 36 1 2 1 0 1 2 33 0.000 1.000 0.057 0.000 0.003 1.000
10 MH Jawa Timur 2015 2024 318 4 22 7 1 3 21 293 0.250 0.955 0.067 0.031 0.564 1.000
11 MH Banten 2015 2024 64 1 16 6 1 0 15 48 1.000 0.938 0.238 0.078 0.588 1.000

Look before moving on. First the counts: in each row, hits, misses, false alarms and quiet should add up to n, and the province rows to the Java row. Then read the Java MK1 row, the main result of the series:

  • most reported drought losses received no payout. Part of that comes from the decade itself: the contract paid in only a few crop years (payout_years), and with the number of payouts it made, it could have paid at most the share of losses in max_p_paid_given_loss, even if every payout had landed on a loss; it paid the share in p_paid_given_loss;
  • a share of the payouts went to unit-seasons without a reported loss (p_noloss_given_paid), but most of the payout hectare-equivalents went to losses (payout_share_to_loss). Some false alarms fall in windows where the unit reported no damage at all (the line above the table): there a payout without a loss may also be a loss that was never reported.

The MH rows rest on very few drought losses: the wet season rarely reports drought, and most MH payouts went to unit-seasons without one, so its rates say little about the contract. The province rows rest on fewer unit-seasons still; read them as description, not as differences between provinces.

7. How sure are these rates?

The rates rest on ten crop years, and the payouts of one crop year move together across Java (Chapter 10). As in Chapter 10, a bootstrap over whole crop years shows the uncertainty: draw ten crop years with replacement, each with all its unit-seasons, recompute the rates, and repeat. Only MK1 is shown; MH has too few losses for intervals to mean anything. This time it is a single query, not a function: setseed runs first, on the same connection, and the draws are listed in a fixed order before random() is called, so that the same seed gives the same draws (Chapter 10). The seed holds for the session, so the seed and the query must share conn, and the same seed gives the same intervals on the same PostgreSQL version. A drawn year that appears twice counts twice: the query keeps the draw number i next to each crop year.

A replicate that draws no paying year has no payouts: P(no loss given payout) and the payout share to loss are then undefined and left out of those two intervals, while P(payout given loss) counts such a replicate as 0. The cell counts these replicates.

BOOT = """
WITH rows AS (SELECT crop_year, paid, loss_event, payout_ha_eq FROM out.basis_risk
              WHERE season = 'MK1' AND NOT provisional),
yrs AS (SELECT array_agg(DISTINCT crop_year ORDER BY crop_year) AS ys FROM rows),
slots AS MATERIALIZED (
    SELECT r.rep, k.i, yrs.ys
    FROM yrs CROSS JOIN generate_series(1, %(replicates)s) AS r(rep)
    CROSS JOIN LATERAL generate_series(1, cardinality(yrs.ys)) AS k(i)
    ORDER BY r.rep, k.i
),
draws AS (SELECT rep, i, ys[random(1, cardinality(ys))] AS crop_year FROM slots),
rep AS (
    SELECT d.rep,
           avg(x.paid::int) FILTER (WHERE x.loss_event) AS p_paid_given_loss,
           avg((NOT x.loss_event)::int) FILTER (WHERE x.paid) AS p_noloss_given_paid,
           coalesce(sum(x.payout_ha_eq) FILTER (WHERE x.loss_event), 0) / nullif(sum(x.payout_ha_eq), 0)
               AS payout_share_to_loss
    FROM draws d JOIN rows x ON x.crop_year = d.crop_year
    GROUP BY d.rep
)
SELECT percentile_cont(ARRAY[0.05, 0.95]) WITHIN GROUP (ORDER BY p_paid_given_loss) AS p_paid_given_loss,
       percentile_cont(ARRAY[0.05, 0.95]) WITHIN GROUP (ORDER BY p_noloss_given_paid) AS p_noloss_given_paid,
       percentile_cont(ARRAY[0.05, 0.95]) WITHIN GROUP (ORDER BY payout_share_to_loss) AS payout_share_to_loss,
       count(*) FILTER (WHERE p_noloss_given_paid IS NULL) AS replicates_without_payout
FROM rep"""
with connect() as conn:                         # setseed and the query on the same connection
    conn.execute("SELECT setseed(%s)", [SEED])
    t = time.perf_counter()
    interval = conn.execute(BOOT, {"replicates": REPLICATES}).fetchone()
java = summary[(summary.season == "MK1") & (summary.province == "Java")].iloc[0]
for name, (lo, hi) in zip(["p_paid_given_loss", "p_noloss_given_paid", "payout_share_to_loss"], interval[:3]):
    print(f"MK1 Java {name}: {java[name]:.3f}, 90% interval {lo:.3f}-{hi:.3f}")
print(f"replicates without any payout: {interval[3]} of {REPLICATES} ({time.perf_counter() - t:.1f} s)")
MK1 Java p_paid_given_loss: 0.274, 90% interval 0.024-0.421
MK1 Java p_noloss_given_paid: 0.361, 90% interval 0.235-0.700
MK1 Java payout_share_to_loss: 0.794, 90% interval 0.520-0.882
replicates without any payout: 49 of 2000 (0.9 s)

percentile_cont(ARRAY[0.05, 0.95]) returns both percentiles at once, as an array. Look before moving on. The intervals are wide: with ten crop years, of which the contract paid in only a few, one drought year more or less changes the rates a great deal. These numbers describe this contract in this decade; they do not pin down how it would do over the next one. Chapter 1 quoted intervals for the same rates from the method review, drawn with 5,000 replicates (ledger L84); their bounds differ from these in the third decimal, the bootstrap’s own noise.

8. Does the index rank the damage at all?

The 2x2 table judges the contract at its trigger. The AUC judges the index itself, before any trigger: it is the chance that a unit-season with a loss has a higher index (drier) than one without, counting ties as half. 0.5 is no better than a coin toss, 1 a perfect ranking. In SQL it is a join of every loss with every non-loss and an average of 1, 0.5 or 0. The event to rank is a parameter of the query text, filled with sql.SQL(...).format(), so that section 10 can score another event with the same query.

Two versions matter. Pooled, all final unit-seasons are compared with each other, across crop years. Within a year, only unit-seasons of the same crop year are compared, the AUC of each year is computed, and the years are averaged with equal weight, whatever their number of losses. A drought year is dry over most of Java (78-87% of the variance of the MK1 index is shared Java-wide, ledger L96), so a pooled AUC can be high simply because the index knows which years were dry; the within-year AUC asks whether, in a given year, it picks out the units that reported damage. That is the harder question, and the one that matters for which units get paid.

AUC = sql.SQL("""
WITH s AS (SELECT crop_year, index_value, {event} AS event FROM out.basis_risk
           WHERE season = %(season)s AND NOT provisional),
pairs AS (
    SELECT l.crop_year AS year_l, n.crop_year AS year_n,
           CASE WHEN l.index_value > n.index_value THEN 1.0 WHEN l.index_value = n.index_value THEN 0.5 ELSE 0 END AS score
    FROM s l JOIN s n ON l.event AND NOT n.event
)
SELECT (SELECT avg(score) FROM pairs)::double precision AS pooled,
       (SELECT avg(a) FROM (SELECT avg(score) AS a FROM pairs WHERE year_l = year_n GROUP BY year_l) y)::double precision
           AS within_year,
       (SELECT count(DISTINCT year_l) FROM pairs WHERE year_l = year_n) AS years_with_both""")
with connect() as conn:
    auc = pd.DataFrame([(s, *conn.execute(AUC.format(event=sql.SQL("loss_event")), {"season": s}).fetchone())
                        for s in ("MK1", "MH")],
                       columns=["season", "auc_pooled", "auc_within_year", "years_with_both"])
auc.round(3)
season auc_pooled auc_within_year years_with_both
0 MK1 0.826 0.569 9
1 MH 0.708 0.605 3

Look before moving on. For MK1 the pooled AUC is high and the within-year AUC much lower, closer to a coin toss: the index knows the dry years well, but within a year it does little to pick out the units that report damage. years_with_both counts the crop years that have both losses and non-losses, the only ones a within-year AUC can use. This is also why Chapter 7 could not settle the MK1 planting date: it was tested against these same damage reports, and none of the four dates tried ranked the units within a year much better than chance (ledger L52). MH has too few drought losses for either number to mean much.

9. The provisional crop year

Crop year 2025 was kept out of every rate so far: its rain is provisional (Chapter 10), and its damage reports are not final either: a month not yet reported reads 0.00 (ledger L19). Its MH ran from October 2025 to April 2026 and its MK1 from April to September 2026. It is also the only crop year that none of the design choices was fitted to: the tests behind the MK1 date and the damage window used crop years up to 2024 (ledger L52, ledger L83). It can serve as a hold-out, data kept back from every choice and used only to check afterwards, with the warning that its rainfall and its reports may still change (ledger L98).

pd.read_sql("""
    SELECT season, count(*) AS n, count(*) FILTER (WHERE loss_event) AS losses, count(*) FILTER (WHERE paid) AS payouts,
           count(*) FILTER (WHERE paid AND loss_event) AS hits,
           round(avg(paid::int) FILTER (WHERE loss_event), 3) AS p_paid_given_loss,
           round(avg((NOT loss_event)::int) FILTER (WHERE paid), 3) AS p_noloss_given_paid
    FROM out.basis_risk WHERE provisional
    GROUP BY season ORDER BY season""", ENGINE)
season n losses payouts hits p_paid_given_loss p_noloss_given_paid
0 MH 99 1 16 0 0.000 1.00
1 MK1 99 21 40 14 0.667 0.65

Look before moving on. One crop year is one draw: whatever it shows, it can neither confirm nor refute the design. It should be read again when the rainfall and the reports for 2025 are final.

10. Exercise: the peril the index does not see

Drought is not the only loss in the reports. In the insured units, the area reported as affected by flood in 2016-2025 is 1.39 times that of drought, and most of it falls in MH windows (ledger L115, ledger L116). The view of section 5 already holds the flood damage. The first cell counts flood events, by the same rule as drought (flood terkena above 1% of paddy), and asks how many MH drought payouts fall on a flood event and how well the MH drought index ranks the flood events; the AUC query of section 8 is reused with another event. It also lists the units with the most MH flood events, to choose a unit for the exercise.

with connect() as conn:
    flood = conn.execute("""
        SELECT count(*) AS n,
               count(*) FILTER (WHERE flood_terkena_ha > 0.01 * paddy_ha) AS flood_events,
               count(*) FILTER (WHERE paid) AS drought_payouts,
               count(*) FILTER (WHERE paid AND flood_terkena_ha > 0.01 * paddy_ha) AS payouts_on_flood_events
        FROM out.basis_risk WHERE season = 'MH' AND NOT provisional""").fetchone()
    flood_auc = conn.execute(AUC.format(event=sql.SQL("flood_terkena_ha > 0.01 * paddy_ha")), {"season": "MH"}).fetchone()
n, events, payouts, on_events = flood
print(f"MH final unit-seasons {n}: flood events {events} ({events / n:.0%}); drought payouts {payouts}, "
      f"of which on a flood event {on_events} ({on_events / payouts:.0%})")
print(f"MH drought index against flood events: AUC pooled {flood_auc[0]:.3f}, within-year {flood_auc[1]:.3f}")
pd.read_sql("""SELECT b.kabupaten_code, u.name,
                      count(*) FILTER (WHERE b.flood_terkena_ha > 0.01 * b.paddy_ha) AS mh_flood_events,
                      count(*) AS mh_seasons
               FROM out.basis_risk b JOIN idx.insured_unit u ON u.code = b.kabupaten_code
               WHERE b.season = 'MH' AND NOT b.provisional
               GROUP BY 1, 2 ORDER BY 3 DESC, 1 LIMIT 6""", ENGINE)
MH final unit-seasons 895: flood events 324 (36%); drought payouts 95, of which on a flood event 26 (27%)
MH drought index against flood events: AUC pooled 0.459, within-year 0.510
kabupaten_code name mh_flood_events mh_seasons
0 3318 Pati 9 9
1 3319 Kudus 9 9
2 3375 Kota Pekalongan 9 9
3 3522 Bojonegoro 9 9
4 3525 Gresik 9 9
5 3601 Pandeglang 9 9

Look before moving on. If the drought payouts were unrelated to floods, the share of them falling on a flood event would be close to the share of flood events among all MH unit-seasons; compare the two percentages. An AUC near or below 0.5 means flood seasons do not sit on the dry side of the drought index. A drought index should not see floods, and it does not. Some units report an MH flood in nearly every crop year: FLOOD_UNIT is one of them.

Could a rainfall index of the other sign see floods? Floods follow very wet spells, and one simple measure of those is the largest five-day rainfall total of a season, called Rx5day here, after a climate-extremes index defined per month or year; the per-season form is this series’ own. It needs daily rainfall over the unit’s paddy, which the series has not stored, so the cell computes it for one unit and season: the paddy-weighted rain of every day (the weight table of Chapter 6 joined to the daily rasters of Chapter 4; true in ST_PixelAsPoints leaves out nodata cells, as in Chapter 6), then a running five-day sum with the window frame ROWS BETWEEN 4 PRECEDING AND CURRENT ROW, which adds each day to the four rows before it, then the maximum. ROWS counts rows, not days, so the cell first checks that no day is missing; the first four days of the season have shorter frames, which cannot raise the maximum since rain is never negative.

RX5 = """
WITH w AS (SELECT col, row, sum(ha) AS ha FROM idx.paddy_weight WHERE kabupaten_code = %(u)s GROUP BY 1, 2),
season AS (SELECT min(s.dekad_start) AS first_day, max(c.dekad_end) AS last_day
           FROM idx.season_dekad s JOIN idx.chirps_dekad c USING (dekad_start)
           WHERE s.kabupaten_code = %(u)s AND s.season = 'MH' AND s.crop_year = %(y)s),
daily AS (
    SELECT r.day, sum(p.val * w.ha) / sum(w.ha) AS mm
    FROM raw.chirps_rnl_daily r
    CROSS JOIN season
    CROSS JOIN LATERAL ST_PixelAsPoints(r.rast, 1, true) p
    JOIN w ON w.col = p.x AND w.row = p.y
    WHERE r.day BETWEEN season.first_day AND season.last_day
    GROUP BY r.day
),
running AS (SELECT day, mm, sum(mm) OVER (ORDER BY day ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) AS mm5 FROM daily)
SELECT (SELECT count(*) FROM daily) AS days,
       (SELECT last_day - first_day + 1 FROM season) AS days_expected,
       max(mm5) AS rx5day_mm,
       (SELECT day FROM running ORDER BY mm5 DESC, day LIMIT 1) AS ends_on,
       max(mm) AS wettest_day_mm,
       (SELECT round(flood_terkena_ha) FROM out.basis_risk WHERE kabupaten_code = %(u)s AND season = 'MH'
          AND crop_year = %(y)s) AS flood_terkena_ha
FROM running"""
t = time.perf_counter()
rx5 = pd.read_sql(RX5, ENGINE, params={"u": FLOOD_UNIT, "y": 2018})
assert rx5.days[0] == rx5.days_expected[0], "a day is missing: the ROWS frame would span more than five days"
print(f"{flood_name}, MH of crop year 2018, in {time.perf_counter() - t:.1f} s")
rx5.round(1)
Pati, MH of crop year 2018, in 1.5 s
days days_expected rx5day_mm ends_on wettest_day_mm flood_terkena_ha
0 100 100 118.8 2019-01-22 42.0 3839.0

Look before moving on. days should equal days_expected, about a hundred, and Rx5day should lie between the wettest day and five times it. The last column is the flood area the unit reported for that season.

Your turn. The series did not build a flood contract, and the reason is measured: tested on the MH flood events, 17 excess-rain indices of this kind, local, over a neighbourhood or Java-wide, ranked them little better than a coin toss (AUC about 0.49 to 0.56), and a flood contract built like the drought one paid no better than random payouts of the same number (ledger L118, ledger L119). The series has no river network, elevation or discharge data, so it cannot test whether river or coastal flooding explains this. To see the pattern for yourself, with FLOOD_UNIT or another unit from the list above:

  1. Compute Rx5day for every MH season of the unit from crop year 2016 to 2024 (loop over y in the cell above, about a second each) and set it against flood_terkena_ha. Expect a weak relation at best.
  2. Compute it also for the crop years 1991-2020 (about 30 more runs), rank each season’s Rx5day against them as Chapter 8 ranks the deficits, and apply a 1-in-5 trigger. In how many of the unit’s flood events would it have paid? Expect about as many as a trigger drawn at random.
  3. Daily CHIRPS rain is the pentad total split into days using ERA5 or IMERG data (ledger L121), so a single day’s extreme is less reliable than a pentad’s. Repeat question 1 with the wettest pentad instead of Rx5day; pentads end on the 5th, 10th, 15th, 20th, 25th and the last day of each month (ledger L153), so group the days with a CASE on the day of the month.

Computing daily rain for all units takes several minutes (ledger L120); start with one.

Checkpoint

The cell below checks, in a new session, what this chapter built:

  • one basis-risk row per payout whose damage window lies inside the damage record, and the provisional flag of every row recomputed from the season end, the window and idx.data_status;
  • the drought damage of one unit-season recomputed from the raw reports;
  • no window with summed puso above summed terkena;
  • in the summary, the four cells adding up to n in every row, and the province rows to the Java row in every count;
  • every rate recomputed from the cells and the sums.

It depends only on the setup cell.

with connect() as conn:
    first_row = lambda q, p=None: conn.execute(q, p).fetchone()
    n_rows, n_expected, wrong_flags = first_row("""
        WITH w AS (SELECT kabupaten_code, season, crop_year,
                          daterange(date_trunc('month', min(dekad_start)::timestamp)::date,
                                    (date_trunc('month', max(dekad_start)::timestamp) + interval '2 months')::date) AS win
                   FROM idx.season_dekad GROUP BY 1, 2, 3),
             e AS (SELECT p.kabupaten_code, p.season, p.crop_year,
                          p.season_end > r.final_through OR upper(w.win) - 1 > d.final_through AS provisional
                   FROM out.payout p JOIN w USING (kabupaten_code, season, crop_year),
                        idx.data_status d, idx.data_status r
                   WHERE d.source = 'datanonkom_dpi' AND r.source = 'chirps_rnl'
                     AND w.win <@ daterange(d.first_day, d.available_through, '[]'))
        SELECT (SELECT count(*) FROM out.basis_risk), (SELECT count(*) FROM e),
               (SELECT count(*) FROM e FULL JOIN out.basis_risk b USING (kabupaten_code, season, crop_year)
                WHERE e.provisional IS DISTINCT FROM b.provisional)""")
    view_ha, raw_ha = first_row("""
        SELECT b.drought_terkena_ha,
               (SELECT coalesce(sum(ha), 0) FROM raw.datanonkom_damage
                WHERE code = %(u)s AND topik = 3 AND variabel_id = 11 AND klasifikasi_id = 2 AND month BETWEEN 1 AND 12
                  AND make_date(year, month, 1) <@ b.damage_window)
        FROM out.basis_risk b WHERE b.kabupaten_code = %(u)s AND b.season = 'MK1' AND b.crop_year = 2018""", {"u": UNIT})
    bad = first_row("""SELECT count(*) FROM out.basis_risk
                       WHERE drought_puso_ha > drought_terkena_ha OR flood_puso_ha > flood_terkena_ha""")[0]
    sums = pd.read_sql("""SELECT season, sum(payout_ha_eq) FILTER (WHERE loss_event) AS ha_eq_loss, sum(payout_ha_eq) AS ha_eq,
                                 sum(drought_terkena_ha) FILTER (WHERE paid) AS dmg_paid, sum(drought_terkena_ha) AS dmg
                          FROM out.basis_risk WHERE NOT provisional GROUP BY season""", ENGINE).set_index("season")
    cells = pd.read_sql("SELECT * FROM out.basis_risk_summary", ENGINE)

assert n_rows > 0 and n_rows == n_expected and wrong_flags == 0, f"{n_rows} rows, expected {n_expected}; wrong flags {wrong_flags}"
assert abs(view_ha - float(raw_ha)) < 1e-6, f"drought terkena {view_ha} in the view, {raw_ha} from the reports"
assert bad == 0, f"{bad} windows with puso above terkena"
assert (cells.hits + cells.misses + cells.false_alarms + cells.quiet == cells.n).all(), "cells do not add up to n"
for season, g in cells.groupby("season"):
    java, prov = g[g.province == "Java"].iloc[0], g[g.province != "Java"]
    for col in ["n", "losses", "payouts", "hits", "misses", "false_alarms", "quiet"]:
        assert prov[col].sum() == java[col], (season, col)
ratio = lambda a, b: np.where(b > 0, a / np.where(b > 0, b, 1), np.nan)
checks = {"p_paid_given_loss": ratio(cells.hits, cells.hits + cells.misses),
          "p_noloss_given_paid": ratio(cells.false_alarms, cells.payouts),
          "p_paid_given_noloss": ratio(cells.false_alarms, cells.false_alarms + cells.quiet),
          "max_p_paid_given_loss": np.minimum(ratio(cells.payouts, cells.losses), 1)}
for col, expected in checks.items():
    assert np.allclose(cells[col].astype(float), expected, rtol=0, atol=1e-12, equal_nan=True), col
java_rows = cells[cells.province == "Java"].set_index("season")
assert np.allclose(java_rows.payout_share_to_loss, sums.ha_eq_loss.fillna(0) / sums.ha_eq, rtol=0, atol=1e-12)
assert np.allclose(java_rows.damage_share_paid, sums.dmg_paid.fillna(0) / sums.dmg, rtol=0, atol=1e-12)
print(f"checkpoint passed: {n_rows:,} unit-seasons scored, provisional flags recomputed, rates recomputed; "
      f"code cells took {time.perf_counter() - T0:.0f} s since the setup cell")
checkpoint passed: 2,083 unit-seasons scored, provisional flags recomputed, rates recomputed; code cells took 14 s since the setup cell

Troubleshooting

Symptom Cause Fix
... is missing: run Chapters 3 to 10 first an earlier chapter has not been run run that chapter first
function random(integer, integer) does not exist PostgreSQL older than 17 upgrade, or draw with 1 + floor(random() * n)::int
windows with summed puso above summed terkena a refresh of the damage reports broke the rule of section 5 look at the listing; if the cause is timing, cap puso at terkena per month (least(puso, terkena)) in damage_month and say so
cannot change name of view column a view was changed in a way CREATE OR REPLACE VIEW does not allow DROP VIEW out.basis_risk_summary, out.basis_risk and run sections 5 and 6 again
cannot drop table ... because other objects depend on it (Chapters 3 to 9) these views read tables of Chapters 3 to 9, and the views of Chapter 10 read out.payout DROP VIEW out.basis_risk_summary, out.basis_risk, out.backtest_summary, out.backtest_year first; never CASCADE
the rates changed after new damage reports were loaded the views read the reports at query time expected; update final_through of datanonkom_dpi in idx.data_status when a year is settled
the Rx5day cell is slow, or reports a missing day it reads every daily raster of the season it computes one unit and season; for many, store the daily rain once in a table

Summary

You now have:

  • out.basis_risk: every scorable unit-season with its payout, its reported drought and flood damage over the season plus one month, a loss flag, and a provisional flag from idx.data_status;
  • out.basis_risk_summary: the 2x2 table and its rates for each season, for Java and for each province, over the final unit-seasons.

The MK1 contract misses most of the drought losses reported in 2016-2025, partly because it paid in few years of that decade; most of its payouts went to losses; its intervals are wide; and its index ranks the dry years far better than the units within a year. The MH contract met too few drought losses to judge, and most of its payouts went to seasons without one. Flood, reported over a larger area than drought, lies outside what a rainfall index on the unit can see. All payouts and rates are illustrative, and the reports they are measured against are reports, not measurements. Chapter 12 maps the payouts.

What comes next

Chapter 12 serves the results from the database to a web map, as vector tiles straight from the tables built in this series.

References