lukeloNgajilo / tanzania-locations-db

Tanzania locations database (Regions -> Districts -> Wards -> Places)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tanzania Locations Repo

Quick Introduction

Tanzania locations, All Regions from Tanzania, with their respective Districts wards & streets.

Very useful for easily implementing Tanzania locations in any application.

How to use

What you need before running the code.

  1. Install & Start Postgresql Db Service

  2. Copy files from location-files to a top level directory /posts/... this is necessary for postgresql Copy command to function as expected refer to this question.

  3. Give user postgres full permissions to /posts directory with

sudo chmod -R postgres:postgres /posts

  1. Create your locations database owned by postgres user

createdb --encoding utf8 --password --owner postgres DATABASE_NAME

Option --password will prompt you to enter password for the Db.

  1. Use psql DATABASE_NAME to enter into the database.

  2. Extract everything

  • Create Tables \i tables_creation.sql

  • Copy regions information to general table with \i general.sql (Don't judge the repetition)

  • Extract countries \i countries.sql

  • Extract all Tanzania locations \i extract.sql

  1. Done!

Room for improvements

  1. Locations (Region, District & Wards) need to use a different auto-incrementing ID field and not it's area code.

The area code should stay as is (in it's field), but there should be a different ID field this will help reduce mixing the IDs once we get broader than just one country.

  1. This whole process can easily be automated.

  2. At least we should start with general.sql as I'm really not proud of it.

  3. API for this will be awesome!

Reference

This data was obtained from TCRA POSTCODE LIST we are by no means fully responsible for it's accuracy.

Credits

Process of data standardization was the most complicated and I was helped by a few friends whom I promised to credit.

  1. Natali Isuja

  2. Joe Master

  3. Robert Mnama

  4. And of course TCRA for publishing this information.

About

Tanzania locations database (Regions -> Districts -> Wards -> Places)


Languages

Language:PLpgSQL 100.0%