Skip to main content

geoalgeria (Python)

Algeria's 69 wilayas, 551 dairas and 1,541 communes, with postal codes, coordinates and Arabic/French search. No dependencies. The data is the GeoAlgeria open dataset, the same one behind the geoalgeria npm package and geoalgeria.com, and search folds names exactly as the npm package does.

pip install geoalgeria
import geoalgeria

geoalgeria.wilaya(31)["name_ar"]          # 'وهران'
geoalgeria.commune(101)["postal_code"]    # '01000'
len(geoalgeria.communes(16))              # communes of Algiers
geoalgeria.dairas(30)                     # dairas of Ouargla
geoalgeria.search("ورقلة")                # Arabic, with or without harakat
geoalgeria.search("bejaia", types=["commune"], limit=5)
geoalgeria.lineage()                      # where each wilaya was before 2019 and 2026
geoalgeria.DATA_VERSION                   # GeoAlgeria data release bundled

Records

Each commune has code_commune, name_fr, name_ar, wilaya_code, daira, postal_code, latitude, longitude, osm_relation_id and wikidata. Wilaya codes follow the 2026 reform (69 wilayas). Each commune also carries wilaya_code_58 and wilaya_code_48: its wilaya on the 58-wilaya map (2019 to 2026) and on the 48-wilaya map (1984 to 2019), so older data joins on the code it was written with.

Each daira has id, name_fr, name_ar, wilaya_code, commune_count, communes (member codes), seat_commune_code, kind (daira, or circonscription in Algiers) and an audit with its status and citation: decree_table when a whole-wilaya decree table names it, agrees_1991 when it matches the 1991 table, and no grade yet otherwise. These are the dataset's 551 checked dairas, not dairas regrouped from the communes.

lineage() returns, for each of the 69 wilayas, its codes on the 58 and 48 maps with the legal texts that say so, plus the commune transfers and the one exception (El Borma).

search(query, limit=10, types=None) returns wilayas, dairas and communes, best first:

>>> geoalgeria.search("ورقله", limit=1)
[{'type': 'wilaya', 'code': 30, 'name_fr': 'Ouargla', 'name_ar': 'ورقلة', 'wilaya_code': 30, 'match': 'loose'}]

match says how the name matched: exact, then prefix (the name starts with what was typed, the last word may be unfinished), then loose (equal or prefix once ى reads as ي and ة as ه). Within each, wilayas come before dairas, then communes, then by French name. A result found only by a former name, such as Lemcene for Lemsane, also has "matched": "former". limit=None returns every match, and types keeps only some of "wilaya", "daira" and "commune".

Accents, harakat, hamza forms, tatweel and case never matter. The same fold is public as conservative_key() and loose_key(), with tokenize() for its words, if you build your own index. They give the same keys as the npm @geoalgeria/normalize, character for character.

Changes in 0.2.0

  • search() results are {type, code, name_fr, name_ar, wilaya_code, match} instead of whole records, and include dairas. Use commune(code) or wilaya(code) for the full record.
  • dairas() returns the audited daira records, each with its communes list of member codes, seat_commune_code and kind.
  • normalize() is deprecated and now returns conservative_key(), which keeps ة and ى as they are. Use loose_key() for the 0.1.0 reading of those two letters. Keys saved with 0.1.0 should be rebuilt.

Licence

Code and the compilation (codes, names, postal codes) are MIT. The OpenStreetMap-derived parts (323 commune centre coordinates, OSM relation ids and Wikidata items) are ODbL 1.0, © OpenStreetMap contributors. Full terms in LICENSE and NOTICE. If you reuse the data, credit GeoAlgeria and OpenStreetMap.

Corrections: open an issue.

Metadata

Release files for geoalgeria 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geoalgeria 0.2.1
File Size Uploaded Provenance Actions
geoalgeria-0.2.1.tar.gz 122.2 kB Without provenance Details for geoalgeria-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for geoalgeria 0.2.1
File Interpreter ABI Platform Actions
geoalgeria-0.2.1-py3-none-any.whl Python 3 none any Details for geoalgeria-0.2.1-py3-none-any.whl

Total release size: 247.7 kB

Release files / geoalgeria-0.2.1.tar.gz

Download URL geoalgeria-0.2.1.tar.gz
Size 122.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e631e6297c24840c65a711b880bf06f80a4d15237fc32913c7a75aac82e761d3
BLAKE2b-256 checksum
How to use checksums
2ee49f5b42acbfc6d7c50e062e2fcce6da13ed3442c2a62067f4457425ed2cd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / geoalgeria-0.2.1-py3-none-any.whl

Download URL geoalgeria-0.2.1-py3-none-any.whl
Size 125.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5115543afbba3abb8e530d71bd423fe02027dbcb3280b298428de552564f503
BLAKE2b-256 checksum
How to use checksums
b32505d51fdfc7d3f4befcf2fc19d1569673a03d7136a016d20201027b266c9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for geoalgeria 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page