Skip to content

feat: add AU and US geometry + region modules#19

Open
sperrot wants to merge 1 commit into
devloed-com:mainfrom
sperrot:feat/add-au-us-geometry
Open

feat: add AU and US geometry + region modules#19
sperrot wants to merge 1 commit into
devloed-com:mainfrom
sperrot:feat/add-au-us-geometry

Conversation

@sperrot

@sperrot sperrot commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Contributes two new country modules for Australia and the United States, following the ATPolygonIndex interface already established in scripts/_lib/at/geometry.py (same resolve / union_all / n_pdo_polygons contract, same (geometry, geom_source, stats) return type).

AU — scripts/_lib/au/

  • geometry.pyAUPolygonIndex backed by the Wine Australia GI Register (official, publicly available SHP/KML). Slug-based name matching handles minor spelling variants across the Zone / Region / Subregion hierarchy (~65 GIs). geom_source = "wine-australia-gi". No Bétard-2022 fallback (EU-only); unresolved GIs return "stub-no-geometry".
    Expected path: raw/au/wine_australia/gi.shp
    Source: https://www.wineaustralia.com/labelling/register-of-protected-gis

  • region.pyderive_state() — returns a 2-letter AU state code (NSW, VIC, QLD, SA, WA, TAS, ACT, NT). Multi-state GIs return the first listed state (Wine Australia convention).

US — scripts/_lib/us/

  • geometry.pyUSPolygonIndex backed by the UCDavis Library AVA corpus (CC0). Keyed by ava_id (e.g. alexander_valley_19841123). Covers all 245 TTB-registered AVAs. geom_source = "ucavis-ava".
    Expected path: raw/us/ucavis/avas.geojson
    Source: https://github.com/UCDavisLibrary/ava (CC0)

  • region.pyderive_state() — returns a 2-letter US state code. Multi-state AVAs (e.g. state = "OR|WA") return the first token (TTB petition convention).

Scope

Geometry and region derivation only — no wiki pipeline content, no eAmbrosia integration (AU/US are outside the EU GI register). These modules slot into stage 04 in the same way as existing EU country modules.

Test plan

  • AUPolygonIndex("raw/au/wine_australia/gi.shp").resolve("Barossa Valley") returns a polygon with geom_source == "wine-australia-gi"
  • AUPolygonIndex.resolve("unknown-gi") returns (None, "stub-no-geometry", {"matched": 0, "unmatched": 0})
  • USPolygonIndex("raw/us/ucavis/avas.geojson").resolve("alexander_valley_19841123") returns a polygon
  • derive_state({"state": "OR|WA"}) returns "OR" (US); derive_state({"state": "NSW|VIC"}) returns "NSW" (AU)
  • find_state_in_text("appellation in South Australia") returns "SA" — longest-match prevents false positive on NSW

🤖 Generated with Claude Code

Contributes two new country modules following the existing ATPolygonIndex
interface (resolve/union_all/n_pdo_polygons contract from _lib/at/geometry.py):

AU (scripts/_lib/au/)
- geometry.py: AUPolygonIndex — loads Wine Australia GI Register
  (SHP or KML, raw/au/wine_australia/gi.shp). Slug-based name matching
  covers the full Zone / Region / Subregion hierarchy (~65 GIs, 2024).
  geom_source = wine-australia-gi. No Figshare fallback (Betard 2022
  is EU-only); missing GIs resolve to stub-no-geometry.
- region.py: derive_state() — returns 2-letter AU state code (NSW,
  VIC, QLD, SA, WA, TAS, ACT, NT). Multi-state GIs return the first
  listed state (Wine Australia convention).

US (scripts/_lib/us/)
- geometry.py: USPolygonIndex — loads UCDavis Library AVA corpus
  (CC0, https://github.com/UCDavisLibrary/ava, raw/us/ucavis/avas.geojson).
  Keyed by ava_id (e.g. alexander_valley_19841123). Covers all 245
  TTB-registered AVAs. geom_source = ucavis-ava.
- region.py: derive_state() — returns 2-letter US state code.
  Multi-state AVAs (state = OR|WA) return the first token (TTB
  petition convention).

Both __init__.py files are empty (mirrors _lib/at/__init__.py).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bdevloed

Copy link
Copy Markdown
Contributor

Thanks for this contribution!

I'll build on top of this for to add the terroir extraction, allowed grapes etc. (if available - US regulation is a bit more relaxed if I remember correctly).

Timeline: coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants