%%{init: {"theme": "neutral"}}%%
flowchart TB
B["Boundaries<br/>BIG 2022"] -->|Ch 3| K["ref.kabupaten<br/>kabupaten/kota"]
D["Damage reports<br/>datanonkom"] -->|Ch 3| DR["raw.datanonkom_damage<br/>damage per month"]
C["Rainfall<br/>CHIRPS v3"] -->|Ch 4| CR["raw.chirps_rnl_daily<br/>one raster per day"]
CR -->|Ch 4| DK["idx.chirps_dekad<br/>dekad rainfall"]
P["Rice fields<br/>MoA 2015"] -->|Ch 5| PF["ref.paddy_moa2015<br/>paddy polygons"]
K --> PF
PF -->|Ch 5| U["idx.insured_unit<br/>99 insured units"]
DK -->|Ch 6| W["idx.dekad_rain<br/>rain over paddy"]
PF --> W
U --> W
W -->|Ch 7| CAL["idx.season_dekad<br/>crop calendar"]
CAL -->|Ch 8| I["idx.season_index<br/>drought index"]
I -->|Ch 9| CT["idx.contract<br/>trigger and exit"]
CT -->|Ch 9| PO["out.payout<br/>payouts"]
PO -->|Ch 10| BT["out.backtest_summary<br/>back-test"]
PO -->|Ch 11| BR["out.basis_risk<br/>basis risk"]
DR --> BR
PO -->|Ch 12| MAP["Web map<br/>vector tiles"]
Chapter 1: Index insurance in one case
Chapter 1: Index insurance in one case
- You will build: Nothing yet: a map of the series, its case and the words used from here on
- You need: No software
- Time to run: About 10 minutes of reading
- Level: Introductory
This series builds one crop insurance contract from start to finish inside a spatial database: rice in Java, paid from a rainfall index, and then checked against the crop damage reported to Indonesia’s Ministry of Agriculture. This first chapter has no code. It explains what an index contract is, why it can fail the farmer it is meant to protect, and how the chapters that follow build each part of it in PostgreSQL and PostGIS from Python.
By the end of this chapter you will be able to:
- explain how an index contract differs from insurance that pays on an assessed loss;
- name the parts of an index contract: insured unit, season, index, trigger, exit and payout;
- define basis risk and its two faces, a loss without a payout and a payout without a loss;
- describe the case: the area, the two rice seasons and the data the series uses;
- say which chapter builds which part, and which numbers in the series are illustrative.
Insurance and Indonesian terms are collected in the table at the end of this chapter.
1. Two ways to insure a harvest
Indonesia’s farm insurance facility pays on an assessed loss. It covers crop failure from natural disasters, pests and climate change, and a claim follows the farmer’s damage report and an inspection (ledger L13). This is indemnity insurance: it pays what was lost, and every claim needs an inspection.
An index contract pays on a number that both sides can observe without inspecting any field. Here that number is computed from rainfall estimates: if the rain in a season falls far enough below normal, the contract pays, whether or not a given field failed. Every insured area follows the same written rule, and the payout can be computed as soon as the rainfall data are final. The contract built in this series covers one peril, drought. Floods and pests are outside it, and section 3 shows what that leaves out.
The series leaves open who would hold the policy (farmers, a farmer group or a local government). A payout is computed per insured unit and applies to all of the unit’s paddy.
The idea has been studied for Indonesia before. A draft World Bank technical note of 2018 designed a parametric drought cover for Central Java on a four-month Standardized Precipitation Index (SPI) computed from 0.5 degree grid cells, with payouts at province level; compared with district rice production for 2006-2015, its correlations ranged from 0.36 to 0.78 (ledger L46). A World Bank feasibility study of 2017 for maize in Eastern Indonesia warned that where production is highly uneven from place to place, “basis risk will likely be so high as to make index insurance problematic” (ledger L47). Section 3 explains the term, and Chapter 11 measures it for this contract.
2. The parts of an index contract
This series describes an index contract by six questions. Two terms first. The sum insured is the money a full payout is worth per hectare. It is left empty in this series because no source for it has been checked yet (ledger L80), so payouts are shown as a share of the sum insured and as hectare-equivalents: the share times the unit’s paddy area, the number of hectares that would be paid in full.
| Part | Question it answers | This series | Built in |
|---|---|---|---|
| Insured unit | Where is the index computed, and who shares one payout? | 99 of Java’s 119 kabupaten and kota (districts and cities): those with at least 1,000 ha of paddy. The 20 left out, all of them kota or Kepulauan Seribu, hold 0.22% of Java’s paddy (ledger L40) | Chapter 5 |
| Season | Which part of the year is insured? | Two rice seasons per crop year, MH and MK1 (section 4), with one fixed planting date per unit derived from its 1991-2020 rainfall | Chapter 7 |
| Index | What number stands for the loss? | Each season is split into three crop stages. In each stage, the rain shortfall below the unit’s 1991-2020 average is ranked against the same stage in the 30 reference years, and the three ranks are averaged into one season index between 0 and 1 (ledger L69, ledger L80) | Chapters 6 and 8 |
| Trigger | When does the contract start to pay? | At the 80th percentile of the unit’s own index over 1991-2020: as dry as the driest 1 year in 5 of its reference period (ledger L80) | Chapter 9 |
| Exit | When does it pay in full? | At the 95th percentile, nominally the driest 1 year in 20 (ledger L80) | Chapter 9 |
| Payout | How much between trigger and exit? | A straight line from 0 at the trigger to the full sum insured at the exit (ledger L80) | Chapter 9 |
The exit is easy to misread. It is not where the contract stops paying, but where the payout reaches 100% of the sum insured; a season drier than the exit still pays 100%. A season whose index lies halfway between its unit’s trigger and exit pays 50%.
3. Basis risk
Basis risk is the gap between what the index says and what happened in the field. It has two faces:
- A loss without a payout. The harvest fails, but the rainfall index of the unit stays below the trigger. This is the failure the insured feel most directly: they were covered and received nothing.
- A payout without a loss. The index triggers, but the fields did well. The premium, the price of the cover, has to pay for these payouts too, so they make the cover dearer.
Basis risk is not a detail to fix later. Clarke (2016) shows that it is what makes rational demand for index insurance differ from demand for indemnity insurance, and that for an infinitely risk-averse buyer the optimal demand for index insurance is zero (ledger L91).
This series measures basis risk against an independent signal: the monthly flood and drought damage that the Ministry of Agriculture publishes per kabupaten (ledger L1), which Chapter 3 collects from its web pages. Chapter 11 builds the comparison, one unit-season at a time: one insured unit in one season of one crop year. A unit-season counts as a loss when the area reported as damaged by drought (terkena, affected) exceeds 1% of its paddy. As a preview, for the MK1 (dry-season) contract in crop years 2015-2024, whose seasons were planted in 2016-2025 (ledger L81):
- 164 of the 226 unit-seasons with a reported drought loss received no payout: 72.6%, with a 90% interval of 57.3-97.6% (ledger L84);
- 35 of the 97 payouts went to unit-seasons below that threshold: 36.1%, 90% interval 23.5-70.0% (ledger L84).
Part of the first number comes from the decade itself: the contract paid in only 3 of these 10 crop years, so at most 97 of the 226 losses could have been paid (ledger L81). And flooding, reported over a larger area than drought (1.39 times the affected area in 2016-2025, ledger L115), is a loss that none of the 17 excess-rain indices tested could detect in the wet season (ledger L118). Chapter 11 ends with that exercise.
4. The case: rice in Java
Area. The six provinces of Java: Banten, DKI Jakarta, Jawa Barat, Jawa Tengah, DI Yogyakarta and Jawa Timur (ledger L26). The paddy-field map used in this series, dated 2015, holds 3,391,572 ha of paddy in Java, 78.0% of it irrigated (ledger L39).
Seasons. The series insures two rice seasons. Each unit gets one fixed date per season on which seedlings are moved from the nursery to the field (transplanting), derived in Chapter 7 from its 1991-2020 rainfall:
- MH (musim hujan, the wet season), planted after the rains begin: transplanted between the dekads (ten-day periods) of 11 October and 11 January depending on the unit, 1 December at the median unit (ledger L125);
- MK1 (musim kemarau pertama, the first dry season), planted after the wet-season harvest and grown into the dry months: transplanted between 1 April and 21 May, 21 April at the median unit, and harvested by the end of August (ledger L125).
A second dry season (MK2) is left out of the contract. Of the drought-affected area (terkena) reported in the insured units in 2016-2025, 88.5% falls in April-September (ledger L49), the months MK1 grows in plus one month, in case damage is reported late. That timing was known when the MK1 planting rule was chosen, and Chapter 7 says so (ledger L52).
The series counts a crop year from 1 August to 31 July, named after the year it starts: crop year 2017 holds the MH transplanted from October 2017 to January 2018 and the MK1 transplanted in April and May 2018 (ledger L125).
Data. Three datasets carry the analysis, on top of the administrative boundaries (ledger L25):
| Dataset | What it gives | Coverage | Chapter |
|---|---|---|---|
| Ministry of Agriculture damage reports (datanonkom.pertanian.go.id) | flood and drought damage to rice per kabupaten and kota and per month, in hectares terkena (affected) and puso (crop failure) (ledger L1) | 2016 onward for every kabupaten and kota in Java (ledger L18) | 3 |
| CHIRPS v3, Climate Hazards Center | rainfall for each five-day period (pentad) from satellite infrared and station data, split into days with ERA5 data, on a 0.05 degree grid (about 5.5 km); licence CC BY 4.0 (ledger L27, ledger L28, ledger L100) | 1981 to near-present | 4 |
| Ministry of Agriculture rice-field map of Java | paddy field polygons, irrigated or rainfed, dated 2015 (ledger L39) | Java | 5 |
The damage reports are reported areas, not measurements. A value of 0.00 can also mean a month that has not been reported yet (ledger L19). The series treats them as one independent signal with its own errors, never as the target a trigger is fitted to; where a design choice did look at the damage, as the MK1 planting date did, the chapter says so.
5. What the database does
Every analysis step of the series is SQL run from Python. The data, the intermediate tables and the results live in one PostgreSQL database with the PostGIS extension, which adds geometry and raster types and functions to PostgreSQL. The tables sit in four schemas, named groups of tables inside the database:
| Schema | Holds | Example |
|---|---|---|
ref |
reference layers that change rarely | boundaries, paddy polygons |
raw |
data as collected | daily rainfall rasters, damage reports |
idx |
the index and the contract | rainfall per unit weighted by paddy area, crop calendar, index, thresholds |
out |
results meant to be read or served | payouts, back-test and basis-risk summaries |
The figure shows how the series moves from its source data to its results, from top to bottom: each box is a source or a table in the database (its name starts with the schema), and each arrow is a step built with SQL, labelled with the chapter that builds it.
Three things follow from keeping it all in one database. Each table is built by a query you can read and run again, so a later chapter, or a colleague, starts from the same queries. Rasters and polygons meet in the same query, which is what turns a rainfall grid into rainfall over paddy fields (Chapter 6). And the results can be served to a web map as vector tiles straight from the tables they are computed in (Chapter 12).
6. What the numbers are, and are not
The contract in this series is a teaching example. Its trigger, exit and payout rule are illustrative choices, documented with their alternatives; they are not an actuarially priced product, and nothing in the series is advice on buying or selling insurance. When a chapter reports what the contract would have paid, read it as “what this rule does with this data”; Chapters 10 and 11 report the uncertainty around those numbers.
Every number in the prose of a chapter comes either from an output cell in that chapter or from a row of the source ledger, linked as “ledger L” followed by the row number. The ledger is published as the sources page of this site, with the script or the primary source behind each row.
Words used in this series
| Word | Meaning here |
|---|---|
| indemnity insurance | insurance that pays the assessed loss after an inspection |
| index, index insurance | a number computed from observed data (here rainfall), and insurance that pays on it |
| insured unit | the area the index is computed for; here a kabupaten or kota |
| kabupaten, kota | regency and city, the district level of Indonesian administration |
| kecamatan | sub-district, one level below the kabupaten |
| paddy (sawah) | a flooded rice field |
| dekad (dasarian) | a ten-day period: days 1-10, 11-20 and 21 to the end of each month |
| crop stage | one of three phases of the rice crop after transplanting: vegetative, reproductive, ripening |
| transplanting | moving rice seedlings from the nursery to the field; the start of each insured season |
| MH, MK1 | the wet season and the first dry season of rice (section 4) |
| crop year | 1 August to 31 July, named after the year it starts |
| unit-season | one insured unit in one season of one crop year |
| normal | the average of the reference period 1991-2020 |
| terkena, puso | reported area affected by damage, and reported area of crop failure |
| trigger, exit | the index levels where payment starts and where it reaches the full sum insured |
| sum insured | the money a full payout is worth, per hectare |
| hectare-equivalent | payout share times paddy area: the hectares that would be paid in full |
| premium | the price of the cover |
| pure premium | the average payout over many years as a share of the sum insured: the premium before the insurer’s costs and margin |
| basis risk | the gap between the index and the loss in the field (section 3) |
Check your understanding
- An MK1 index lies three quarters of the way from its unit’s trigger to its exit. What share of the sum insured is paid?
- A kabupaten reports drought damage on 5% of its paddy in June, but its MK1 index stays below the trigger. Which face of basis risk is this?
- Why can the contract built here not pay for flood damage, however large?
Answers: 75%; a loss without a payout; it covers one peril, drought, and its index measures only rain below normal.
Summary
Nothing exists in the database yet. You now have the vocabulary of the series and its plan: the table in section 2 names each part of the contract and the chapter that builds it.
What comes next
Chapter 2 installs PostgreSQL, PostGIS and the Python packages, creates the tutorial database and checks that Python can reach it.
References
- Clarke (2016). American Economic Journal: Microeconomics 8(1), 283-306, doi:10.1257/mic.20140103 (ledger L91)
- Climate Hazards Center. CHIRPS v3. doi:10.15780/G2JQ0P, https://www.chc.ucsb.edu/data/chirps3 (ledger L27)
- Peraturan Menteri Pertanian 30/2023, amended by 36/2025: Indonesia’s farm insurance facility, https://peraturan.bpk.go.id/Download/320056/Permentan%20Nomor%2030%20Tahun%202023.pdf (ledger L13)
- World Bank (2017), feasibility study of weather index insurance for maize in Eastern Indonesia, http://documents.worldbank.org/curated/en/261291490700705164/pdf/113760-WP-WII-for-Maize-Production-in-Eastern-Indonesia-PUBLIC.pdf (ledger L47)
- World Bank (2018), draft technical note on parametric drought insurance for Indonesia, http://documents.worldbank.org/curated/en/704171524632990898/pdf/Technical-Note.pdf (ledger L46)