indiaciv, part 4: Economics as game yields

Strategy games boil a tile down to a few numbers: how much food it grows, how much it produces, how much money and research it brings in. Part 3 put people on the map. This part does the same for the economy, with one constraint I didn’t want to break: every yield is a real quantity in real units, and adds back up to a published statistic.

yieldwhat it isunitsource totalspread over the map by
Foodcereals + pulses + oilseeds production, 2023-24tonnes / yrper district (DES via UPAg)cropland
Productionindustry value added (mining, manufacturing, utilities, construction), 2023-24₹ crore / yrper state (RBI / NSO)night lights
Goldservices value added, 2023-24₹ crore / yrper state (RBI / NSO)√(night lights × population)
Scienceuniversities, research institutes, collegespointspoints in OpenStreetMapwhere they are
CultureWorld Heritage Sites, museums, theatres, historic sitespointspoints in OSM and Wikidatawhere they are

The five yields across India: food, production, gold, science and culture, each on a log colour scale

The first three are statistics that only exist per district or per state, so the work is deciding where inside the district or state they go. The last two are already points on a map, so they only need counting. Both kinds go through the same own_state rule from part 3, so nothing crosses a state border.

The machinery: total × weight

All three statistical yields use dasymetric allocation (part 3): take a unit’s published total TuT_u and spread it over the unit’s cells or hexes in proportion to a weight ww:

Yh=∑uTu∑c∈u∩hwc∑c∈uwc Y_h = \sum_u T_u \frac{\sum_{c \in u \cap h} w_c}{\sum_{c \in u} w_c}

Each unit’s weights are normalised to sum to 1, so each state or district keeps its total exactly. The whole design question is the choice of ww: where inside a state is its industry? Each answer below is a hypothesis about that, and I’ll say where it’s weak.

Food: crops over cropland

The Directorate of Economics and Statistics publishes crop area and production by district, season and crop. I use the 2023-24 figures via the UPAg portal, summing cereals, pulses and oilseeds. It comes to 369.7 million tonnes, and make validate checks India’s total lands between 300 and 450 Mt.

Each district’s total is spread over the district’s cropland: WorldCover class 40 pixels, at about 800 m. Crops grow on cropland, a rare weight that’s close to the literal truth. The remaining error is that a district’s yield per hectare is treated as uniform. Irrigated and rain-fed land in the same district get the same tonnes per hectare.

The hard part wasn’t the maths. It was names. The crop table lists 738 districts for 2023-24, and my district polygons are the 642 of Census 2011. Telangana, Ladakh and dozens of new districts all came after 2011. For each name in the crop table, matching tries, in order:

  1. data/overrides.csv, a hand-checked table of 165 rows that maps each renamed or newer district to the 2011 district containing it. Budgam is Badgam in 2011 and Poonch is Punch. Fazilka, carved out of Firozpur in 2011, goes to Firozpur, so its wheat is spread over the right fields.
  2. An exact match within the same state, after normalising both names (lower case, “&” to “and”, dropping “district” and “the”, then keeping only letters).
  3. A fuzzy match within the state (difflib, cutoff 0.84) to absorb small spelling drift.

All 738 districts match. If one ever didn’t, its production would go to its state’s cropland, so no tonne is silently lost. Keeping the mapping in a CSV rather than in code means fixing a district needs no code change.

Production: industry over night lights

India’s GDP by state comes from the National Statistical Office, and the RBI Handbook tabulates it by sector: Net State Value Added for industry (mining, manufacturing, electricity and gas, construction) and for services, at current prices. For 2023-24 that’s one number per state per sector. Three territories (Ladakh, Lakshadweep, and Dadra & Nagar Haveli and Daman & Diu) aren’t reported, so their values are estimated from the national per-capita figure times their population, and flagged as estimates in the data.

To place industry inside a state I use night lights: VIIRS annual radiance for 2024, summed per hex. Factories, refineries, ports and mines are lit all night, and night-time light as a proxy for economic activity is well established in economics. It’s an imperfect proxy: it overweights brightly lit highways and gas flares and underweights activity that happens in the dark, but it’s far better than area or population.

Gold: services over √(lights × people)

Services (trade, transport, finance, IT, public administration, health, education) follow both activity and people. A district hospital serves its population whether or not the town is brightly lit, and a software park is bright whatever the local population. So the gold weight is the geometric mean of the two:

whgold=Lh⋅Ph w_h^{\text{gold}} = \sqrt{L_h \cdot P_h}

On a log scale that sits exactly halfway between the two. How different are they? Here is each hex’s share of India’s night lights relative to its share of India’s people:

Map of each hex’s share of night lights relative to its share of population: red where lights exceed people (Gujarat, Punjab, Haryana, the Pune and Hyderabad corridors), blue where people exceed lights (the Gangetic plain, Bihar, Kerala)

The Gangetic plain is deep blue: enormous population, comparatively little light. Gujarat, Punjab, Haryana and the corridors around Pune and Hyderabad are red. Production follows the red, so industrial value sits in the industrial belts. Gold leans halfway back toward the blue. Allocating services by lights alone would pull Bihar’s services into its few brightly lit towns, and allocating by people alone would treat a village and an IT park as the same per head.

Run the numbers per city and the richest in gold is New Delhi, which make validate checks.

Science and culture: counting points

These two aren’t statistics but points, so they’re simple sums of weighted features from an OpenStreetMap extract of India, read with pyosmium:

yieldfeaturepoints
scienceuniversity10
scienceresearch institute4
sciencecollege1
cultureUNESCO World Heritage Site (from Wikidata)25
culturemuseum3
culturetheatre, arts centre2
culturefort, palace, castle, archaeological site, monument, ruins, city gate1

The weights are judgement calls; there is no official number to check them against. Two rules are not judgement calls. Places of worship are never counted, and the map has no religion, caste or language layers, a rule I set at the start. A temple-dense district shouldn’t read as “more cultured”, and a layer counting them invites exactly the comparisons this map shouldn’t make. OSM coverage is also uneven: a well-mapped city scores higher than an equally rich, less-mapped one. These two yields measure the map as much as the territory.

Checking it adds up

Every statistical yield is checked state by state against its source: food for the 34 states and UTs in the crop data, production, gold and night lights for all 36. The tolerance is 2%:

State totals of food, production, gold and night lights on the hex map against their sources, all on the diagonal

They sit on the diagonal because allocation conserves totals by construction. The check is there for when something breaks that construction: a district that stops matching, a unit mix-up, a change to own_state. There are spot checks too: Punjab’s cities must score high on food (Ludhiana 28, Amritsar 24, Bathinda 30 out of 30).

Lenses: a hex in a byte

The browser shows each yield, and ten other layers, as a colour overlay called a lens. To keep the bundle small, every lens is stored as one byte per hex: 29,583 bytes per lens before compression, whatever the units.

Byte 0 means “no data”. Bytes 1–255 map onto the lens’s range [min⁡,max⁡][\min, \max], either linearly or, for anything that spans orders of magnitude, logarithmically:

q=1+round⁡(254⋅ln⁡(v/min⁡)ln⁡(max⁡/min⁡)),v≈min⁡⋅(max⁡min⁡)(q−1)/254 q = 1 + \operatorname{round}\left(254 \cdot \frac{\ln(v / \min)}{\ln(\max / \min)}\right), \qquad v \approx \min \cdot \left(\frac{\max}{\min}\right)^{(q-1)/254}

The range comes from the data, the 2nd to 99.7th percentile, rounded outward to a 1-2-5 step (so the legend reads “200 to 500,000”, not “213 to 487,331”). The manifest records min, max and log for each lens, and the browser decodes with the same formula. Try it:

The real lens ranges from the manifest. On a log lens every byte step is the same ratio, so the decoding error is under about 1.5% everywhere; on a linear lens small values lose more.

On a log lens every step is the same ratio, so the error is a constant ±1–2% from one end of the range to the other. That’s well below the uncertainty of anything being shown. Fifteen lenses, 29,583 hexes each: 116 KB for all of them, brotli-compressed.

Next: climate and resources

Part 5 covers the rest: IMD’s 30-year rainfall and temperature normals (and a temperature bug that made the Himalaya warmer than Shimla), monsoon share, where the tea, coffee, spice and mineral icons come from, and how roads and railways were snapped onto the grid.