{"id":15647672,"url":"https://github.com/kalebu/mtaa","last_synced_at":"2025-04-30T11:14:11.154Z","repository":{"id":37772990,"uuid":"332081700","full_name":"Kalebu/mtaa","owner":"Kalebu","description":"A package consisting of all Tanzania locations from region to streets in an easily accessible way","archived":false,"fork":false,"pushed_at":"2021-05-24T11:35:15.000Z","size":1950,"stargazers_count":45,"open_issues_count":0,"forks_count":12,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-30T11:14:10.550Z","etag":null,"topics":["mtaa","python-mtaa","python-tanzania","python-tanzania-locations","tanzania","tanzania-locations","tanzania-regions-package"],"latest_commit_sha":null,"homepage":"https://kalebu.github.io/mtaa-docs/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kalebu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"patreon":"kalebujordan"}},"created_at":"2021-01-22T22:55:54.000Z","updated_at":"2025-02-25T08:25:05.000Z","dependencies_parsed_at":"2022-08-18T17:52:20.185Z","dependency_job_id":null,"html_url":"https://github.com/Kalebu/mtaa","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kalebu%2Fmtaa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kalebu%2Fmtaa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kalebu%2Fmtaa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kalebu%2Fmtaa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kalebu","download_url":"https://codeload.github.com/Kalebu/mtaa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251687157,"owners_count":21627534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mtaa","python-mtaa","python-tanzania","python-tanzania-locations","tanzania","tanzania-locations","tanzania-regions-package"],"created_at":"2024-10-03T12:20:33.510Z","updated_at":"2025-04-30T11:14:11.106Z","avatar_url":"https://github.com/Kalebu.png","language":"Python","funding_links":["https://patreon.com/kalebujordan","https://www.patreon.com/kalebujordan"],"categories":[],"sub_categories":[],"readme":"# [mtaa](https://pypi.org/project/mtaa)\n\n[![Downloads](https://pepy.tech/badge/mtaa)](https://pepy.tech/project/mtaa)\n[![Downloads](https://pepy.tech/badge/mtaa/month)](https://pepy.tech/project/mtaa)\n[![Downloads](https://pepy.tech/badge/mtaa/week)](https://pepy.tech/project/mtaa)\n\nA package consisting of all Tanzania locations from region to streets in a easy accessible way made by [kalebu](https://github.com/kalebu)\n\n[![Become a patron](pictures/become_a_patron_button.png)](https://www.patreon.com/kalebujordan)\n\n## A strory behind\n\nMtaa package is result of organized **json** of all the locations in Tanzania, As I was looking for data about these locations data I came across repo [tanzania-location-db](https://github.com/HackEAC/tanzania-locations-db), It consists of locations data organized into *regions*, whereby each region has its own csv file. So I wrote a script to transform all the locations from csv into a single **Json** and from there package came.\n\n## Json Transformer\n\nIf you wanna give a look at the script or interested about building your Json from a similar kind of raw data here is [Json Transformer script](https://github.com/Kalebu/mtaa/blob/main/json_transformer.py). \n\n## Installation\n\nUse pip to install it just as shown below;\n\n```bash\npip install mtaa\n```\n\n## Usage \n\nThe library is very straight forward, at the very top of the library is country which is tanzania and at the very bottoms are places in a given street, here is a sample;\n\n```python\n\u003e\u003e\u003e from mtaa import tanzania\n\n\u003e\u003e\u003e tanzania\n['Shinyanga', 'Mara', 'Dar-es-salaam', 'Kilimanjaro', 'Kagera', 'Tanga', 'Mwanza', 'Tabora', 'Kigoma', 'Pwani', 'Ruvuma', 'Mtwara', 'Morogoro', 'Rukwa', 'Katavi', 'Simiyu', 'Geita', 'Arusha', 'Iringa', 'Mbeya', 'Njombe', 'Manyara', 'Lindi', 'Singida', 'Songwe', 'Dodoma']\n\n\u003e\u003e\u003e tanzania.Mbeya.districts\n['Mbeya cbd', 'Mbeya', 'Rungwe', 'Mbarali', 'Kyela', 'Chunya]\n \n \n\u003e\u003e\u003e tanzania.Mbeya.districts.Rungwe.wards\n['ward_post_code', 'Bulyaga', 'Bagamoyo', 'Makandana', 'Msasani', 'Kawetele', 'Itagata', 'Ibigi', 'Kyimo', 'Suma', 'Masoko', 'Mpuguso', 'Malindo', 'Lufingo', 'Kiwira', 'Nkunga', 'Ikuti', 'Kisondela', 'Ilima', 'Bujela', 'Masukulu', 'Kisiba', 'Kabula', 'Lupata', 'Kambasegela', 'Kisegese', 'Itete', 'Lufilyo', 'Lwangwa', 'Mpombo', 'Isange', 'Kandete', 'Luteba', 'Isongole', 'Kinyala', 'Matwebe', 'Masebe', 'Swaya', 'Iponjola', 'Lupepo', 'Ndanto', 'Ntaba', 'Mpata']\n\n```\n\n## How about the Type?\n\n```python\n\u003e\u003e\u003e from mtaa import tanzania\n\u003e\u003e\u003e type(tanzania)\n\u003cclass 'mtaa.Tanzania'\u003e\n```\n\nAs you can see the repr() being shown on of the REPL is of type \u003cmtaa.Tanzania\u003e, you can easily convert it into native python datatypes due to the fact its iteratable, as shown in the example below;\n\n```python\n\u003e\u003e\u003e from mtaa import tanzania\n\u003e\u003e\u003e list(tanzania)\n['Shinyanga', 'Mara', 'Dar-es-salaam', 'Kilimanjaro', 'Kagera', 'Tanga', 'Mwanza', 'Tabora', 'Kigoma', 'Pwani', 'Ruvuma', 'Mtwara', 'Morogoro', 'Rukwa', 'Katavi', 'Simiyu', 'Geita', 'Arusha', 'Iringa', 'Mbeya', 'Njombe', 'Manyara', 'Lindi', 'Singida', 'Songwe', 'Dodoma']\n```\n\nSince its Iterable that's means you can loop through it, but as string for  Example;\n\n```python\n\u003e\u003e\u003e for district in tanzania.Mbeya.districts:\n...     print(district)\n... \nMbeya cbd\nMbeya\nRungwe\nMbarali\nKyela\nChunya\n```\n\n## How about Dar-es-salaam ?\n\nIn the above example we were able to retreive locations of **Mbeya** region because, Mbeya is a valid python identifier, when you try to access **Dar-es-Salaam** it will ofcourse raise you an error just as shown below;\n\n```python\n\u003e\u003e\u003e from mtaa import tanzania\n\u003e\u003e\u003e tanzania.Dar-es-salaam\nTraceback (most recent call last):\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\nAttributeError: 'Tanzania' object has no attribute 'Dar'\n```\n\nTo resolve this at anypoint where you a location name is an invalid identifier, use get_dict() instead of (.) operator to access it as shown in the example below;\n\n```python\n\u003e\u003e\u003e from mtaa import tanzania \n\u003e\u003e\u003e tanzania.get('Dar-es-salaam').districts\n['Ilala cbd', 'Ilala', 'Kinondoni', 'Temeke', 'Ubungo', 'Kigamboni']\n```\n\n## Fetching the whole tree\n\nLets you want to extract no just names in a ward but the whole ward and its deeper roots, to do this use the tree () at any given instance with exception of places in streets which are just list;\n\nHere an example (Some places in Tanzania)\n\n```python\n\u003e\u003e\u003e home = tanzania.Mbeya.districts.Rungwe.wards.Kiwira.tree()\n\u003e\u003e\u003e print(home)\n{'ward_post_code': '53515', 'streets': {'Mpandapanda': ['Ipoma', 'Kiwira kati', 'Mpandapanda', 'Ilongoboto', 'Isange'], 'Kikota': ['Lukwego', 'Lubwe', \"Kang'eng'e\", 'Ilamba', 'Kikota', 'Ipande'], 'Ibula': ['Kibumbe', 'Ibula', 'Kanyegele', 'Sanu - salala kalongo', 'Katela'], 'Ilundo': ['Bujinga', 'Ibagha a', 'Buswema', 'Ibagha b', 'Kanyambala', 'Lusungo'], 'Ilolo': ['Ibigi', 'Ilolo', 'Itekele', 'Masebe', 'Masugwa', 'Kisungu']}}\n\n```\n\n## Grouped Locations\n\nYou can also access grouped locations such as all districts, wards and street as shown below;\n\n```python\n\u003e\u003e\u003e import mtaa\n\u003e\u003e\u003e mtaa.wards\n......\n\u003e\u003e\u003e len(mtaa.wards)\n3964\n\u003e\u003e\u003e mtaa.districts\n......\n\u003e\u003e\u003e len(mtaa.districts)\n158\n\u003e\u003e\u003emtaa.streets\n.....\n\u003e\u003e\u003e len(mtaa.streets)\n16741\n```\n\n## From other languages ?\n\nIncase you're from other languages than Python you might wanna take a look at these general purpose APIS\n\n- [MtaaAPI](https://github.com/HackEAC/mtaaAPI)\n- [Location-api](https://github.com/HackEAC/locations-API)\n\n## Give it a star\n\nIf you found this repository useful, give it a star so as the whole galaxy of developer can get to know it, you can also keep in touch with me on [twitter](https://twitter.com/j_kalebu).\n\n## Bug bounty?\n\nIf you encounter **issue** with the usage of the package, feel free raise an **issue** so as \nwe can fix it as soon as possible(ASAP) or just reach me directly through email isaackeinstein(at)gmail.com.\n\n## Pull Requests\n\nIf you have something to add I welcome pull requests on improvement , you're helpful contribution will be merged as soon as possible\n\n## Disclaimer\n\nAll the location I used to build this repository, I got from an public repository titled [tanzania-locations-db](https://github.com/HackEAC/tanzania-locations-db), I'm not responsible for any kind of misinformation in it, I tried to locate my home with it found its pretty accurate, so use it to your own risk\n\n## Credits\n\nAll the credits to ;\n\n- [kalebu](github.com/kalebu)\n- [HackEAC](https://github.com/HackEAC/tanzania-locations-db)\n- Future contributors\n\n## Related Opensource Projects\n\n- [MtaaAPI](https://github.com/HackEAC/mtaaAPI)\n- [Location-API](https://github.com/HackEAC/locations-API)\n- [rgeocode](https://github.com/bentesha/rgeocode)\n- [Reverse geocoder](https://github.com/Kalebu/reverse-geocoder)\n- [tanzaniageodata](https://github.com/Kijacode/tanzaniageodata)\n- [location-demographia](https://github.com/dbrax/location-demographia)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalebu%2Fmtaa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkalebu%2Fmtaa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalebu%2Fmtaa/lists"}