Hire
The platform Request a hire Locum cover
Find work
Jobs Locum shifts CV builder CV writing service Cover letters
Pricing About
Sign in Create account
Updated · 3 min read

kenya-geo: how we put every Kenyan job in the right county

Job adverts describe places in a hundred ways. We built kenya-geo, an open-source Go package with every county, constituency, ward and post office in Kenya, to turn them into one clean answer.

On this page
  1. What is kenya-geo?
  2. Why not just match county names?
  3. What happens when a place name is ambiguous?
  4. How does it keep foreign jobs off the site?
  5. Where else does Monica use the data?
  6. Can I use it?

Monica lists jobs from across Kenya, and most of them reach us from other job boards and employers' careers pages. Every one of those sources writes locations differently. One advert says "Westlands, Nairobi", another says "Syokimau", another "Muranga County", and some just say "Airport" or "Remote, KE". To show a nurse in Eldoret the jobs nearby, we need every one of those strings turned into the same thing: a county.

That is the job of kenya-geo, an open-source Go package we maintain. This post explains what is in it and how Monica uses it.

What is kenya-geo?

kenya-geo is Kenya's administrative geography as a Go library: all 47 counties, 290 constituencies, 1,450 wards and 890 post offices, with IEBC ward codes, ISO 3166-2 codes, 2019 census figures and map coordinates. The data is compiled into the binary, so there is nothing to download or configure when it runs, and it has no dependencies outside the Go standard library. It is MIT licensed and anyone can use it.

geo := kenyageo.Default()
c, _ := geo.CountyByName("murang'a")
fmt.Println(c.Code, c.Name, c.Headquarters) // 21 Murang'a County Murang'a

Name lookups are forgiving: case, apostrophes, dashes and a trailing "County" do not matter, so "Muranga County" and "Murang'a" find the same place.

Why not just match county names?

Because most adverts do not name the county. They name a town, an estate, a ward or a constituency, and Kenya has a lot of them. "Syokimau" is in Machakos. "Diani" is in Kwale. "Mwingi" is in Kitui. "Voi" is in Taita-Taveta. A list of 47 county names gets none of those right. With every ward, constituency, county headquarters and post office in one place, our crawler can recognise almost any place an advert mentions and work out which county it belongs to.

What happens when a place name is ambiguous?

Some names belong to more than one county, and some words that look like places are not places at all. "Central", "Airport", "Township" and "Market" appear all over the country. We would rather leave a job without a county than put it in the wrong one, so names that point to more than one county are left out of the lookup, and generic words are ignored. A job in "Airport" gets no county; a job in "Airport, Embakasi" does.

We keep real-world examples as tests, from "Ongata Rongai, Kajiado" to "Luxembourg City", and every change to the matching has to pass all of them.

How does it keep foreign jobs off the site?

Many international boards mix Kenyan roles with jobs in Lagos, London or Dubai. Before a crawled job is saved, the crawler checks whether its location mentions anywhere in Kenya, using the same place names. "Thika Road, Kiambu" and "Remote, KE" pass. "Voice Coach, London" and "Lagos, Nigeria" do not.

Where else does Monica use the data?

The crawler exports the counties, constituencies and wards to JSON, and the rest of Monica reads that file. The place pickers on our forms use it, so candidates and employers choose their county, constituency and ward from real lists instead of typing them. Our Django code uses it to file jobs by county, and an audit command checks stored locations against it and reports anything that no longer matches.

Having one source of truth means the crawler, the website and the database all agree on where a place is.

Can I use it?

Yes. Install it with go get github.com/rmiyoyo/kenya-geo; it needs Go 1.24 or later. As well as name lookups it can find the ward, constituency and county for a coordinate, return ward and county boundaries as GeoJSON, parse and check postal addresses, and run as a small JSON API. The documentation is on pkg.go.dev, and mapping-kenya is a website built on it.

If you find a place it gets wrong, open an issue on GitHub. Every fix makes Monica's job listings more accurate too.

Hiring, handled

Looking for work in Kenya? Browse open jobs and build a free CV. Hiring? We find, check and shortlist the right people for you.

Browse jobs Request a hire
First published Read as Markdown

Keep reading