Skip to main content

Geocode a file of addresses

In this tutorial you geocode a six-line file of addresses in one command. You then read four things from the results: how precise each coordinate is, the record that supplied it, the place candidates the geocoder weighed, and whether the address resolved at all. The file mixes US and French streetstreetThe named linear feature along which house numbers are ordered. Decomposes into a name plus street affixes; one of the Tier 2 fine labels. addresses, a citylocalityThe city / town / settlement component of an address: a populated place sitting between region and neighborhood in the hierarchy. without a streetstreetThe named linear feature along which house numbers are ordered. Decomposes into a name plus street affixes; one of the Tier 2 fine labels., and two inputs that should stay unresolved.

Before you start​

  • Node.js ^24.22.3 || >=26.13.1
  • ECMAScript module project with "type": "module" in its package.json
  • Start by installing the required packages:

    sh
    npm install mailwoman

    The geocoder reads geographic data from a local directory. Choose a data directory, then download the global place candidates, the French address pointssitus dataA dataset of exact address-point coordinates (rooftop-level). Mailwoman's geocoder uses a national situs layer (124.9M US points built from state address-point sources) as the highest-precision tier of the geocode cascade., and the address pointssitus dataA dataset of exact address-point coordinates (rooftop-level). Mailwoman's geocoder uses a national situs layer (124.9M US points built from state address-point sources) as the highest-precision tier of the geocode cascade. for Washington, DC and Vermont:

    sh
    export MAILWOMAN_DATA_ROOT="$HOME/mailwoman-data"

    npx mailwoman data pull candidate fr
    npx mailwoman data pull us --only us-dc
    npx mailwoman data pull us --only us-vt

    The four pulls download about 10.2 GB: candidate 2.9 GB, fr 7 GB, DC 127.5 MB and Vermont 132.2 MB. The candidate bundleevidence bundleThe pair of retrieval-augmented input channels (street-type + locality-surface) that feed lexicon membership as soft per-token evidence alongside the text. Shipped in 6.7.0; trained natively from step 0 in the from-scratch base line. resolves places such as cities and regionsregionThe first-level administrative subdivision of a country — a US state, a French region, a province. The component between country and locality. worldwide. The fr and us files add individual address pointssitus dataA dataset of exact address-point coordinates (rooftop-level). Mailwoman's geocoder uses a national situs layer (124.9M US points built from state address-point sources) as the highest-precision tier of the geocode cascade.. Add --dry-run to any pull to see its plan and size first. Data and locales lists every bundleevidence bundleThe pair of retrieval-augmented input channels (street-type + locality-surface) that feed lexicon membership as soft per-token evidence alongside the text. Shipped in 6.7.0; trained natively from step 0 in the from-scratch base line..

    The output below was captured with local builds of these bundlesevidence bundleThe pair of retrieval-augmented input channels (street-type + locality-surface) that feed lexicon membership as soft per-token evidence alongside the text. Shipped in 6.7.0; trained natively from step 0 in the from-scratch base line. that are newer than the 11.0.0 registry entries. A coordinate or source release in your output can differ.

    1. Write the address file​

    Save these six lines as addresses.txt:

    text
    1600 Pennsylvania Ave NW, Washington, DC 20500
    1 Main St, Burlington, VT 05401
    Springfield, IL
    12 Rue de Rivoli, 75001 Paris, France
    Main Street
    qwerty asdf

    2. Geocode the file​

    Run the geocoder over the file. --stdin reads one address per line and loads the modelneural classifierThe machine learning model at the core of Mailwoman's parser — a transformer encoder (~30M parameters) trained from scratch to do BIO token classification over addresses. It learns the 'grammar' of address formats; the gazetteer supplies the 'atlas.' and data once for the whole file. It writes one JSON object per line:

    sh
    npx mailwoman geocode --stdin < addresses.txt > results.jsonl

    The command exits 0, and results.jsonl has six lines, one for each input line, in the same order.

    3. Read one result​

    Open the first line of results.jsonl. These are the fields that describe its coordinate. The full object has 31 fields, and the result schema describes each one:

    json
    {
    "input": "1600 Pennsylvania Ave NW, Washington, DC 20500",
    "components": {
    "region": "DC",
    "locality": "Washington",
    "postcode": "20500",
    "street": "Pennsylvania Ave NW",
    "house_number": "1600"
    },
    "lat": 38.89767510742324,
    "lon": -77.03654697024702,
    "resolution_tier": "address_point",
    "epistemic_status": "observed",
    "uncertainty_m": 1,
    "countryCode": "US",
    "coordinate_source": {
    "source": "overture:NAD",
    "release": "2026-05-20.0"
    },
    "rooftop": {
    "localityNorm": "washington",
    "postcode": "20500"
    }
    }

    components is what the parser read from the text. resolution_tier: "address_point" means the coordinate is one recorded address point for this house numberhouse numberThe numeric or alphanumeric identifier of a building on a street. Mailwoman's house_number component; its position relative to the street name flips between locales. and streetstreetThe named linear feature along which house numbers are ordered. Decomposes into a name plus street affixes; one of the Tier 2 fine labels.. coordinate_source identifies the register that supplied that point and its release: the US National Address Database, as distributed in the Overture MapsOverture MapsAn open consortium (Meta, Microsoft, AWS, TomTom) publishing Places and Addresses themes with GERS entity IDs. A candidate gazetteer source for POIs and street-level addresses. release 2026-05-20.0. rooftop holds the localitylocalityThe city / town / settlement component of an address: a populated place sitting between region and neighborhood in the hierarchy. and postcodepostcodeThe country-specific postcode (US ZIP, French code postal, etc.). Mailwoman handles postcode parsing entirely by rule classifier — a regex problem, not an ML one. stored on that address-point record. Those values describe the matched record rather than your input.

    4. Compare the six results​

    Save this script as summarize-results.ts. It prints the tier, status, coordinate and source of each result. The GeocodeRow interface declares the fields the script reads:

    ts
    import { readFileSync } from "node:fs"

    interface GeocodeRow {
    input: string
    lat: number | null
    lon: number | null
    resolution_tier: string
    epistemic_status: string
    coordinate_source: { source: string; release: string } | null
    }

    const rows: GeocodeRow[] = readFileSync("results.jsonl", "utf8")
    .trim()
    .split("\n")
    .map((line) => JSON.parse(line))

    for (const row of rows) {
    const where = row.lat == null || row.lon == null ? "no coordinate" : `${row.lat.toFixed(5)}, ${row.lon.toFixed(5)}`
    const source = row.coordinate_source ? `${row.coordinate_source.source} ${row.coordinate_source.release}` : "-"

    console.log(`${row.input}\n ${row.resolution_tier} / ${row.epistemic_status} · ${where} · source: ${source}`)
    }

    Run it:

    sh
    node summarize-results.ts
    text
    1600 Pennsylvania Ave NW, Washington, DC 20500
    address_point / observed · 38.89768, -77.03655 · source: overture:NAD 2026-05-20.0
    1 Main St, Burlington, VT 05401
    address_point / observed · 44.47572, -73.21949 · source: overture:NAD 2026-05-20.0
    Springfield, IL
    admin / observed · 39.79733, -89.64555 · source: -
    12 Rue de Rivoli, 75001 Paris, France
    address_point / observed · 48.85560, 2.35995 · source: ban:fr 2026-05-18
    Main Street
    admin / unresolved · no coordinate · source: -
    qwerty asdf
    admin / unresolved · no coordinate · source: -

    Three streetstreetThe named linear feature along which house numbers are ordered. Decomposes into a name plus street affixes; one of the Tier 2 fine labels. addresses resolved to address pointssitus dataA dataset of exact address-point coordinates (rooftop-level). Mailwoman's geocoder uses a national situs layer (124.9M US points built from state address-point sources) as the highest-precision tier of the geocode cascade.. The two US points came from the National Address Database (overture:NAD). The Paris point came from France's Base Adresse Nationale (ban:fr). The source tells you which public register to check if a point looks wrong.

    Springfield, IL resolved at the admin tier. The input gives a citylocalityThe city / town / settlement component of an address: a populated place sitting between region and neighborhood in the hierarchy. and a state without a streetstreetThe named linear feature along which house numbers are ordered. Decomposes into a name plus street affixes; one of the Tier 2 fine labels., so the coordinate is a representative point for the citylocalityThe city / town / settlement component of an address: a populated place sitting between region and neighborhood in the hierarchy.. Its coordinate_source is null because no address record supplied the coordinate.

    5. Inspect the place candidates​

    The third line of results.jsonl shows how the geocoder chose that Springfield. Its hierarchy and candidates fields are reformatted onto fewer lines here:

    json
    {
    "hierarchy": [
    {
    "tag": "locality",
    "value": "Springfield",
    "name": "Springfield",
    "lat": 39.797328,
    "lon": -89.645547,
    "placeID": "wof:85940429",
    "in_winner_lineage": true
    },
    {
    "tag": "region",
    "value": "IL",
    "name": "Illinois",
    "lat": 40.265028,
    "lon": -89.191575,
    "placeID": "wof:85688697",
    "in_winner_lineage": true
    }
    ],
    "candidates": [
    {
    "name": "Springfield",
    "tag": "locality",
    "lat": 39.797328,
    "lon": -89.645547,
    "countryCode": "US",
    "placeID": "wof:85940429",
    "score": 5.0513262055058465
    },
    {
    "name": "Springfield",
    "tag": "locality",
    "lat": 39.860743,
    "lon": -89.695816,
    "countryCode": "US",
    "placeID": "wof:1729438673",
    "score": 0
    },
    {
    "name": "Springfield Township",
    "tag": "localadmin",
    "lat": 39.860743,
    "lon": -89.695743,
    "countryCode": "US",
    "placeID": "wof:404498567",
    "score": 3.737987326333431,
    "matchedAlias": true
    }
    ]
    }

    The geocoder weighed two Illinois localities called Springfield and the localadmin Springfield Township, and selected the highest-scoring localitylocalityThe city / town / settlement component of an address: a populated place sitting between region and neighborhood in the hierarchy., Who's On FirstWOF (Who's On First). An open-source gazetteer of places maintained by Mapzen/whosonfirst. Mailwoman builds a custom SQLite database from WOF GeoJSON repos, extended with postcode data, importance scores, and coincident-role relations. place wof:85940429. hierarchy lists that localitylocalityThe city / town / settlement component of an address: a populated place sitting between region and neighborhood in the hierarchy. and the Illinois regionregionThe first-level administrative subdivision of a country — a US state, a French region, a province. The component between country and locality. it sits in. When two candidates score close together, the input is ambiguous, and your application can ask for more detail instead of accepting the first result.

    6. Find the rows that didn't resolve​

    The last two inputs have no coordinate. Their epistemic_status is unresolved, and lat and lon are null. Their resolution_tier still reads admin, so filter on epistemic_status or on a null coordinate rather than on the tier.

    Each unresolved row records its reason in intent_markers. For Main Street, the marker states that a streetstreetThe named linear feature along which house numbers are ordered. Decomposes into a name plus street affixes; one of the Tier 2 fine labels. needs at least streetstreetThe named linear feature along which house numbers are ordered. Decomposes into a name plus street affixes; one of the Tier 2 fine labels. precisionprecisionOf the spans the model labeled as a given tag, the fraction it got right. High precision means few false positives. Paired with recall to compute F1. and that the lookup reached only the admin tier:

    json
    {
    "kind": "locality_only",
    "code": "declared_coarser_answer",
    "mechanism": "resolver:tier_shortfall",
    "message": "The query supplied street, which is located no coarser than street, and the walk reached admin. The coordinate below is the admin-grade one; it does not locate the street.",
    "evidence": {
    "unusedComponents": ["street"],
    "requiredTier": "street",
    "reachedTier": "admin"
    }
    }

    For qwerty asdf, the parser read the text as the localitylocalityThe city / town / settlement component of an address: a populated place sitting between region and neighborhood in the hierarchy. Qwerty Asdf, and no place matches it. Its marker states that the two words can be read as two places or as one place with its regionregionThe first-level administrative subdivision of a country — a US state, a French region, a province. The component between country and locality.. Keep unresolved rows in your output with their null coordinate, and send them to review.

    What you have now​

    results.jsonl holds one geocode result for each line of addresses.txt, produced by one --stdin run with one modelneural classifierThe machine learning model at the core of Mailwoman's parser — a transformer encoder (~30M parameters) trained from scratch to do BIO token classification over addresses. It learns the 'grammar' of address formats; the gazetteer supplies the 'atlas.' and data load, and summarize-results.ts prints each result's tier, status, coordinate and source. Each result's candidates list shows the places the geocoder weighed, and each unresolved row keeps its null coordinate, epistemic_status: "unresolved" and an intent_markers entry that gives the reason.

    Read how geocoding chooses a coordinate for what each tier means, and the CLI reference for every geocode flag.