> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To set up Hatchmark for a user, follow https://hatchmark.dev/docs/get-started/agent-setup.md. Inside a Hatchmark project, prefer `hatchmark docs`: it prints the docs of the installed version.

# Map boundaries

> The built-in geographies behind Hatchmark maps (US states and counties, world countries, and the states, provinces and regions of nine countries): boundary sources, region ids, projections, disputed areas and row matching.

Hatchmark draws choropleth and proportional symbol maps from built-in geographies: `us-states`, `us-counties` and `world-countries`, and the first-level divisions of nine countries: `canada-provinces`, `uk-nations`, `uk-regions`, `germany-states`, `france-regions`, `australia-states`, `india-states`, `brazil-states`, `mexico-states` and `japan-prefectures`. All ship as pre-projected SVG paths, so a map needs no projection code or boundary download at run time. Every module stays under 40 KB gzipped except the county module, which also carries each county's 2024 population estimate and stays under 210 KB, and a page carries only the geographies its maps draw.

## Sources

| Geography | Source | Version | Licence |
| - | - | - | - |
| `us-states` | U.S. Census Bureau cartographic boundary files, via [us-atlas](https://github.com/topojson/us-atlas) `states-10m.json` | us-atlas 3.0.1 (`us-atlas@3.0.1+hm1`) | Census data: public domain; us-atlas: ISC |
| `us-counties` | U.S. Census Bureau [cartographic boundary file](https://www.census.gov/geographies/mapping-files/time-series/geo/cartographic-boundary.html) `cb_2024_us_county_20m` | 2024 (`census-cb-2024-20m+hm1`) | Public domain |
| `world-countries` | [Natural Earth](https://www.naturalearthdata.com/) 1:110m admin 0 countries; names, codes and locations of smaller countries from the 1:10m file | 5.1.2 (`natural-earth@5.1.2+hm2`) | Public domain |
| `canada-provinces` | Natural Earth 1:10m admin 1 states and provinces | 5.1.2 (`natural-earth@5.1.2+hm1`) | Public domain |
| `uk-nations` | Natural Earth 1:10m admin 1, the UK's local authorities merged into England, Scotland, Wales and Northern Ireland | 5.1.2 (`natural-earth@5.1.2+hm1`) | Public domain |
| `uk-regions` | Natural Earth 1:10m admin 1, the UK's local authorities merged into the 12 ITL1 regions | 5.1.2 (`natural-earth@5.1.2+hm1`) | Public domain |
| `germany-states` | Natural Earth 1:10m admin 1 states and provinces | 5.1.2 (`natural-earth@5.1.2+hm1`) | Public domain |
| `france-regions` | Natural Earth 1:10m admin 1, France's departments merged into its 18 regions | 5.1.2 (`natural-earth@5.1.2+hm1`) | Public domain |
| `australia-states` | Natural Earth 1:10m admin 1 states and provinces | 5.1.2 (`natural-earth@5.1.2+hm1`) | Public domain |
| `india-states` | Natural Earth 1:10m admin 1 states and provinces | 5.1.2 (`natural-earth@5.1.2+hm1`) | Public domain |
| `brazil-states` | Natural Earth 1:10m admin 1 states and provinces | 5.1.2 (`natural-earth@5.1.2+hm1`) | Public domain |
| `mexico-states` | Natural Earth 1:10m admin 1 states and provinces | 5.1.2 (`natural-earth@5.1.2+hm1`) | Public domain |
| `japan-prefectures` | Natural Earth 1:10m admin 1 states and provinces | 5.1.2 (`natural-earth@5.1.2+hm1`) | Public domain |

`scripts/build-boundaries.ts` (`pnpm gen:boundaries`) downloads the files at pinned versions, checks their SHA-256, projects them, simplifies them and writes `src/geo/world-codes.ts` and one boundary module per geography in the renderer package: `packages/render/src/geo/us-states.ts`, `us-counties.ts`, `world-countries.ts` and one per country geography, such as `canada-provinces.ts`. The country geographies all come from one Natural Earth file, pinned to the same commit as the world map, so their outer borders agree with each other. Where Natural Earth's first-level units are smaller than the divisions people report by (the UK's local authorities, France's departments), the generator merges them along their shared borders. Counties come from the Census Bureau's own 2024 file rather than us-atlas, whose counties predate Connecticut's planning regions (2022) and the split of Alaska's Valdez-Cordova Census Area (2019). The `+hm1` suffix numbers Hatchmark's own processing of a source version. Simplification is Visvalingam's area method on the projected shapes, with every point shared by two regions kept or dropped on both sides together, so neighbours never open gaps or overlap. Coordinates are rounded to 0.1 viewBox units.

## Region ids

* `us-states`: the USPS code, such as `CA` or `DC`.
* `us-counties`: the 5-digit FIPS code, such as `06037`. Display names carry the state: "Los Angeles County, CA".
* `uk-regions`: the ITL1 code, such as `TLI` for London. ITL1 (International Territorial Levels, the UK's successor to NUTS 1) splits England into nine regions and keeps Scotland, Wales and Northern Ireland whole.
* The other country geographies: the current ISO 3166-2 code, such as `CA-ON`, `GB-SCT`, `DE-BY`, `FR-IDF`, `AU-NSW`, `IN-DL`, `BR-SP`, `MX-CMX` or `JP-13`. India uses the codes ISO adopted in 2023 (`IN-OD`, `IN-CG`, `IN-TS`, `IN-UK`) and Mexico City is `MX-CMX`; the older codes still match. Corsica is `FR-20R`, and the overseas regions of France use their three-digit codes, such as `FR-974` for Réunion. Display names are the usual English names: "Quebec", "Bavaria", "Brittany", "Mexico City", "State of Mexico", "Tokyo".
* `world-countries`: the ISO 3166-1 alpha-3 code, such as `USA`. Natural Earth leaves out the ISO code of France and Norway in its main column; Hatchmark reads them from Natural Earth's fallback column, so they are `FRA` and `NOR`. Regions with no ISO code use Natural Earth's `ADM0_A3` code: Kosovo is `KOS`, Northern Cyprus `CYN` and Somaliland `SOL`.

Every region also has an English display name ("California", "United States", "Côte d'Ivoire"), a label point inside its largest polygon (where a symbol map centres its circle), and its projected area in viewBox units squared, so a renderer can tell when a region is too small to label in place.

## Projections

**us-states** uses an Albers equal-area conic projection (standard parallels 29.5° and 45.5°, as in Albers USA) for the lower 48 states and DC, in a 975 × 610 viewBox. Alaska, Hawaii and Puerto Rico sit in boxed insets along the bottom left: Alaska at 0.3 times the main scale, Hawaii at the main scale and Puerto Rico at 1.25 times, so it stays visible. The strip right of the map is kept free for labels of the states too small to label in place (VT, NH, MA, RI, CT, NJ, DE, MD and DC): each has a `leader` position in a column there, ordered top to bottom, for a leader line from its label point.

**us-counties** uses the projections and inset frames of us-states, so a county sits exactly where its state does. It has no leader labels. Its `outlines` are the state lines: every border two counties of different states share, drawn once over the counties. Coasts are left to the land's edge. Each county also carries its resident population from the Census Bureau's Vintage 2024 county estimates for July 1, 2024 (`cc-est2024-agesex-all.csv` and, for Puerto Rico, `cc-est2024-agesex-72.csv`; public domain), which the ranked list uses as its base.

**Country geographies** fit their longer side to 975 units, with an equal-area projection centred on the country: Albers conic for Canada (parallels 50° and 70° N), Germany, France, Australia (18° and 36° S), India, Mexico and Japan, Lambert azimuthal for Brazil, and for the UK a transverse Mercator on 2° W, as the British National Grid. `france-regions` boxes the five overseas regions in a column of insets on the left (Guadeloupe, Martinique, French Guiana, Réunion, Mayotte), each at its own scale. `japan-prefectures` boxes Okinawa Island and its neighbouring islands in an inset at the top left.

A map leaves out an inset its data never names. When no row of the sources a map block reads names a region drawn in an inset (for `us-counties`, any current or retired county of that state), over all time with no period, dashboard filter or metric filter applied, and some row names a region the map draws, the map draws neither the inset frame nor its regions. The viewBox is then cropped to what is left, keeping the original margins, so the rest of the map grows into the space where the layout allows: a `us-states` map without its three insets is 975 × 585, a `france-regions` map without the overseas column 835 × 779. A `us-states` tile map leaves out the tiles of those insets instead. The block's `hiddenInsets` lists the insets left out, by inset id.

**world-countries** uses the Equal Earth projection, 975 wide. Antarctica is removed and the empty southern ocean is cropped. Shapes that cross the antimeridian (Russia, Fiji) are cut at it rather than wrapped.

## Territories and small countries

Puerto Rico is drawn as an inset. Guam, the U.S. Virgin Islands, American Samoa and the Northern Mariana Islands are not drawn: at this scale each would be a few pixels, and drawing them would take four more insets. They are listed in the geography's `notDrawn`, so rows naming them are reported as "not drawn" instead of "unmatched".

us-counties draws every county the 2024 file has. Counties retired since 2010 are listed in its `notDrawn`, because data from earlier years, and some current data sets, still use them: Connecticut's eight counties (09001 to 09015, replaced by nine planning regions), Valdez-Cordova Census Area (02261, split into Chugach and Copper River), Wade Hampton Census Area (02270, now Kusilvak), Shannon County, SD (46113, now Oglala Lakota) and Bedford city, VA (51515, now part of Bedford County).

The country geographies leave out a few remote islands so the main map isn't shrunk to fit them: Lord Howe and Macquarie Islands (Australia), the Ogasawara and other Pacific islands of Tokyo, the Daitō, Miyako and Yaeyama Islands of Okinawa (the area left out also holds the Senkaku (Diaoyu) Islands, so they are not drawn either), Fernando de Noronha and Trindade (Brazil), and Guadalupe and the Revillagigedo Islands (Mexico). Their rows still match their state or prefecture. Natural Earth files the Amami Islands under Okinawa although they belong to Kagoshima, so they are drawn as part of Kagoshima. Australia's Jervis Bay Territory is not drawn, and its rows are unmatched. `france-regions` lists the 16 regions France merged in 2016, such as Alsace and Rhône-Alpes, as not drawn (the six that kept their borders are the current regions), and `india-states` lists Dadra and Nagar Haveli and Daman and Diu, merged in 2020; data from earlier years still uses them, and their rows can't be given to a current region without double counting or splitting.

The world map draws the shapes Natural Earth's 1:110m file contains. Countries and territories too small for it (Singapore, Malta, Andorra, Bahrain, Hong Kong and others) are regions marked `dot`, with an empty path and a label point at their 1:10m label point, so a map draws them as dots. French Guiana and Svalbard, which the 1:110m file draws as part of France and Norway, are split out and drawn as shapes of their own; a map whose data has no rows for them draws them as part of France and Norway again. The other ISO territories Natural Earth includes in another country (Réunion, Bouvet Island and seven others) are dots, at a location Hatchmark sets by hand. Every ISO 3166-1 country and territory is drawn, as a shape or a dot, except Antarctica: its label point falls below the map's frame, so it is listed in `notDrawn` and matched the same way.

## Disputed areas

Boundaries follow Natural Earth's default, de facto lines; Hatchmark does not edit the geometry. In the 1:110m data this means:

* Crimea is drawn as part of Russia.
* Kashmir is divided along the lines of actual control: the Indian-administered part with India, the Pakistani-administered part with Pakistan, Aksai Chin with China.
* Western Sahara (`ESH`) covers the area east of the Moroccan berm; the area west of it is drawn with Morocco.
* Taiwan (`TWN`), Kosovo (`KOS`), Northern Cyprus (`CYN`) and Somaliland (`SOL`) are drawn as their own regions.
* The Golan Heights are drawn with Israel.

`india-states` follows the same default lines. Jammu and Kashmir and Ladakh cover the area India administers; the Pakistani-administered part of Kashmir and Aksai Chin are not drawn as part of India, and Arunachal Pradesh is drawn with India. Maps published in India show India's claimed boundary. Hatchmark keeps one neutral source for every viewer rather than a version per country, so these maps match the world map.

## Focus presets

Presets for a map's `focus` on `world-countries`. Names match ignoring case, spaces and punctuation,
and `&` reads as `and`, so `Latin America & the Caribbean` works too.

| Preset | Countries |
| - | - |
| `africa`, `americas`, `asia`, `europe`, `oceania` | UN M49 regions, from the [UN Statistics Division](https://unstats.un.org/unsd/methodology/m49/overview/). |
| `northern-africa`, `sub-saharan-africa`, `eastern-africa`, `middle-africa`, `southern-africa`, `western-africa`, `latin-america-and-the-caribbean`, `caribbean`, `central-america`, `south-america`, `northern-america`, `central-asia`, `eastern-asia`, `south-eastern-asia`, `southern-asia`, `western-asia`, `eastern-europe`, `northern-europe`, `southern-europe`, `western-europe`, `australia-and-new-zealand`, `melanesia` | UN M49 sub-regions and intermediate regions. Micronesia and Polynesia are left out: each of their countries is only a dot at the map's scale. |
| `eu27` | The 27 member states of the European Union ([european-union.europa.eu](https://european-union.europa.eu/principles-countries-history/eu-countries_en)). |
| `mena` | Middle East and North Africa as the IMF groups it in its Regional Economic Outlook: Middle East and Central Asia (October 2025): 22 countries and territories, without Israel or Türkiye. |

UN M49 does not list Taiwan, Kosovo, Northern Cyprus or Somaliland, which the world map draws; the
presets place each with its neighbour (Eastern Asia, Southern Europe, Western Asia and Eastern
Africa). Northern Cyprus and Somaliland are drawn inside the borders of Cyprus and Somalia, so any
focus with Cyprus or Somalia takes them too. When the data has no rows for Northern Cyprus,
Somaliland, French Guiana or Svalbard, a map that also shows Cyprus, Somalia, France or Norway draws
the territory as part of that country, so it takes the country's colour instead of reading as
missing data.

The frame fits each country's main body and each dot it draws, so overseas parts such as Alaska or
Hawaii don't stretch it. `europe` and `eastern-europe` colour all of Russia but frame the
continent, so Russia is cut at the frame's eastern edge.

A focus country too small to draw, such as Singapore or Malta, is a dot at its location. A dot more
than about 1,000 km, and more than 15% of the frame's longer side, outside the other countries'
frame is left out of the drawing, such as Bouvet Island in `latin-america-and-the-caribbean`. A
preset with a frame of its own leaves out every country with no land inside that frame, dot or
shape, such as Svalbard in `europe`. Such a country keeps its value, rank, share and bar list row,
and a note under the map names it: "Not drawn, outside the frame: Bouvet Island." A focus of dots
alone, such as `focus: [Singapore]`, is framed at least about 2,000 km across, so the map shows
the dot's neighbourhood.

## Matching rows to regions

A map's region column is matched to region ids through an alias table per geography:

* `us-states`: USPS code, full name, FIPS code with or without the leading zero (`06`, `6`), ISO 3166-2 (`US-CA`), and common abbreviations (`Calif.`, `Mass.`, `N.Y.`, `Wash. D.C.`, `Washington DC`, `D.C.`).
* `us-counties`: the 5-digit FIPS code, with or without the leading zero, and the name with its state as code or name: `Los Angeles County, CA`, `Los Angeles, CA`, `Los Angeles County, California`. `St.` and `Ste.` also match `Saint` and `Sainte`. A name without its state never matches, and a typo is only compared with the counties of the state it names.
* Country geographies: the ISO 3166-2 code with or without the country prefix (`CA-QC`, `QC`), older ISO codes (`IN-OR`, `MX-DIF`, `FR-GP`; France's lettered pre-2016 codes: those of the 16 regions merged in 2016, such as `FR-A` for Alsace, count as the old regions, so they are not drawn, and those of the six regions that kept their borders, such as `FR-E` for Brittany, match the current region), postal abbreviations (`NSW`, `P.E.I.`, `NRW`, `CDMX`), the statistics office's numeric code (Statistics Canada, the German AGS, INSEE, the ABS, IBGE, INEGI and the Japanese prefecture code, with or without the leading zero), the English name, the local name and common forms: `Bayern` and `Bavaria`, `Québec` and `Quebec`, `NCT of Delhi`, `Orissa`, `Île-de-France`, `Ciudad de México` and `Distrito Federal`, `Aichi`, `Aichi-ken`, `Aichi Prefecture` and `愛知県`. `uk-nations` matches the ONS GSS codes of the nations (`E92000001`) and the NUTS 1 and ITL1 codes of Scotland, Wales and Northern Ireland (`UKM`, `TLM`), and `uk-regions` matches the GSS codes of the regions (`E12000007`) and the old NUTS 1 codes (`UKI`). A name in a non-Latin script, such as `愛知県`, is matched as written, apart from spaces at its ends.
* `world-countries`: ISO alpha-2, alpha-3 and numeric codes (with or without leading zeros), Natural Earth's name fields, and common, World Bank, IMF and UN styles such as `UK`, `Russian Federation`, `Korea, Rep.`, `Türkiye`, `Lao PDR`, `Gambia, The` and `Hong Kong SAR, China`. Kosovo also matches `XK` and `XKX`.

Before matching, values are normalized:

1. A code is ASCII digits, optionally followed by a zero fraction (`06`, `6.0`, `06.00`), with or without spaces around it. It loses its leading zeros (`006` → `6`), so a DOUBLE column of FIPS or ISO numeric codes matches like an integer one.
2. Anything else is a name. A fixed fold table spells out letters that have no accent to strip: `ß` → `ss`, `æ` → `ae`, `ø` → `o`, `ł` → `l`, ligatures such as `ﬁ`, and full-width letters.
3. Accents are removed, the text is lowercased, `&` becomes "and", every run of other characters (spaces, punctuation, apostrophes) becomes one space, and the ends are trimmed.
4. A name left without Latin letters is compared as written, with only the whitespace at its ends removed, including the full-width space U+3000. So `北海道` matches. But it is never read as a code: signed or bracketed numbers (`-6`, `−06`, `+6`, `(6)`, `6-`), full-width digits (`６`), decimals (`6.5`) and digits padded with other spaces are reported as unmatched.

So `Côte d’Ivoire`, `COTE-D'IVOIRE` and `cote d ivoire` are the same key. The same normalization runs in DuckDB when a query groups or joins by region, and a test checks that both give the same key for every Unicode character.

An alias that names more than one region is never matched: `Congo` (COD or COG), `Korea` (KOR or PRK) and `Virgin Islands` (VGB or VIR) on the world map, `Carolina` and `Dakota` on the US map, and a name that is both a county and an independent city of one state, such as `Fairfax, VA` or `Baltimore, MD`, on the county map. A value that matches nothing gets up to three suggestions, the regions whose names are a likely typo away ("Calfornia" suggests CA). Netherlands rows must say "Netherlands", not "Holland".


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.