Morocco’s 1,503 communes, as open data.

Official HCP codes, names in French and Arabic, population from the 2024 and 2014 censuses, what they found about people and homes, the establishments the last one mapped, and a boundary for every commune but one. Free to use.

  • < 10
  • 10–50
  • 50–150
  • 150–500
  • 500–2,000
  • 2,000+
  • no boundary

people per km², 2024

1,502 communes, from the boundaries this API serves.Every commune, by région© OpenStreetMap contributors, ODbL

12
régions
83
provinces and préfectures
213
cercles
1,503
communes
41
arrondissements

How a code reads

Each group of digits names a level, so a commune’s code already contains its province and its région. Cercles sit above rural communes only; an urban commune may hold arrondissements instead.

codeHow a code readsPopulation, 2024
01Tanger-Tétouan-Al Hoceimarégion4,030,222
01.511Tanger-Assilahpréfecture1,494,413
01.511.05Tangercercle60,807
01.511.05.19Hjar Ennhalcommune27,204
01.511.01.0Tangercommune1,275,428
01.511.01.05Mghoghaarrondissement252,656

What the numbers show

The south is filling up

Population change by région between the 2014 and 2024 censuses.

  • Dakhla-Oued Ed-Dahab+53.9%
  • Laâyoune-Sakia El Hamra+22.6%
  • Tanger-Tétouan-Al Hoceima+13.3%
  • Souss-Massa+12.8%
  • Casablanca-Settat+12.1%
  • Rabat-Salé-Kénitra+12.0%
  • Marrakech-Safi+8.2%
  • Fès-Meknès+5.5%
  • Guelmim-Oued Noun+3.4%
  • Drâa-Tafilalet+1.3%
  • Béni Mellal-Khénifra+0.2%
  • Oriental−0.9%

Dakhla-Oued Ed-Dahab grew by more than half. The Oriental is the only région that shrank. Each bar is summed from the région’s communes.

Most communes are small

Communes by 2024 population.

  • <2k: 64
  • 2–5k: 243
  • 5–10k: 452
  • 10–25k: 515
  • 25–50k: 125
  • 50–100k: 56
  • 100k+: 48

Half the people, under 1% of the land

The 121 densest communes, against the other 1,382.

Share of the population, 2024
Share of the land

Most communes lost people

Communes that lost or gained people between the censuses. Overall, urban +12.8%, rural +3.0%.

Rural communes
792 lost people, 466 gained
Urban communes
63 lost people, 178 gained

lost peoplegained

What the two censuses found

5 rates HCP published in 2014 and again in 2024, for Morocco, each asked the same way both times.

  • Can’t read or write32.2%24.8%Can’t read or write: 32.2% in 2014, 24.8% in 2024.
  • Higher education6.1%10.2%Higher education: 6.1% in 2014, 10.2% in 2024.
  • Unemployment16.2%21.3%Unemployment: 16.2% in 2014, 21.3% in 2024.
  • Running water73.0%82.9%Running water: 73.0% in 2014, 82.9% in 2024.
  • Electricity91.6%97.1%Electricity: 91.6% in 2014, 97.1% in 2024.

20142024

Whether the crosswalk holds up

207 communes were renumbered by the 2015 reform, so their 2014 population had to be matched by name and elimination rather than read off an unchanged code. If those matches were wrong, their implied growth would scatter differently.

Code unchanged since 20141,286: median −2.0%, middle half −10.8% to +7.3%, 10th to 90th percentile −18.0% to +22.5%Renumbered, matched by the crosswalk207: median −3.8%, middle half −11.8% to +5.2%, 10th to 90th percentile −19.1% to +23.5%

The bar spans the 10th to 90th percentile, the block the 25th to 75th, the line the median. The 2 distributions nearly overlap, so the matches look sound. The crosswalk’s README gives the reasoning for each pair.

Run a query

Requests go to the live API.

French, Arabic or a slug. Accents and Arabic letter variants fold, and old names work too: Fez finds Fès, Port Lyautey finds Kénitra.

RequestGET /api/search?q=Fez&limit=5

Pick an example or type a query, then run it.

Build on it

Where a request is answered

The X-Api-Tier header says where a request was answered. A static file has none, since nothing ran.

  1. A file on the CDN

    no header, because nothing ran

    11,629 responses are written when the site’s built, and cost nothing to serve.

  2. A rewrite to that file

    X-Api-Tier: alias

    A query string can’t pick a file, so requests written that way are resolved to the file that already holds the answer, and the response names it.

  3. Worked out on the spot

    X-Api-Tier: computed

    Search, point and radius queries, and filter combinations no single file covers. These are the only requests that spend anything.

Take the whole thing

Every file here is built from the dataset in the repository, which works without the API too. Boundaries, and every figure drawn from them, are under ODbL. The README describes each field.