Monday, January 20, 2020

Convert HEXEWKB to Latitude/Longitude in python


from shapely import wkb

hexlocation_list = ["0101000020E6100000AECB9307F9D812400F2ADCE003704940", 
                    "0101000020E6100000E40AAE6CD6DA1240941F95531C704940", 
                    "0101000020E6100000C0D7C68E7CD81240F550364044704940", 
                    "0101000020E6100000CB752BC86AC8ED3FF232E58BDA7E4440", 
                    "0101000020E6100000DB81DF2B5F7822C0DFBB7262B4744A40"]


for hexlocation in hexlocation_list:
    point = wkb.loads(hexlocation, hex=True)
    
    longitude, latitude = point.x, point.y
    print(longitude, latitude)





Related articles:
1- How to convert HEXEWKB to Latitude, Longitude (in python)?


Monday, January 13, 2020

Making the Map of 10 States Ready To Pay N30,000 Minimum Wage

President Buhari had in April 2019 signed the new wage bill aimed at boosting the morale of the Nigerian workers into law.

According to Nigeria Labour Congress (NLC), only ten (10) states listed below met the December 31, 2019 deadline set by organised labour. NLC had on December 11, 2019 at a meeting with its state chairmen in Abuja, set December 31 of the same year for all state governors to conclude negotiations with workers in their states following an agreement with the Federal Government on October 18, 2019.

As GIS practitioners, lets visualize these 10 states on a map to see if we can deduce any spatial pattern!

The 10 states are:-

  • Abuja (Federal Level)
  • Adamawa
  • Bauchi
  • Borno
  • Jigawa
  • Kaduna
  • Kano
  • Katsina
  • Kebbi
  • Lagos and
  • Ebonyi



Mapping Steps

Step 1:
Get the vector map of Nigeria in shapefile format. You can download one from HERE (State, LGA and Wards) or from GADM Data web portal.



Step 2:
Load the state shapefile into your favorite GIS software, here I will use QGIS.


Step 3:
Select the 10 states from the list above that met the NLC December 31, 2019 minimum wage deadline.

You can do this selection from the attribute table or by simply selecting from the map directly. Then give them a different color from the remaining states.

Here I will use green color for states that met with the deadline and white for those that didn't.



To make the selection the query will look like this: "state_name" in  ('fct', 'Adamawa', 'Bauchi', 'Borno', 'Jigawa', 'Kaduna', 'Kano', 'Katsina', 'Kebbi', 'Lagos', 'Ebonyi')

The final map as seen below:-


From the resulting map, there are some spatial patter readily seen such:-

  • Most of the northern states responded to the deadline.
  • Most of the wealthy states with oil wells failed to met up with the deadline.
  • States with larger land mass responded well
  • ect

We can now begin to ask some spatial related questions to uncover some possible reasons why it was easy for these states to met the 30,000 wage on time.

  • Does this has to do with the states low/high population?
  • Does it has to do with the states' generated revenue?
  • Does it means the Governors of those states have more sympathy for it's workers?
  • Or cold it be because the states are oil producing states and receives high allocation from you he federal government?
  • etc
Off curse, this is simple case map that a graphic oriented software such as coreldraw or photoshop can easily do. But think Spatially to uncover hidden information!

Thursday, January 9, 2020

City-Data.com Zip Codes Data Wrangling

Here I found myself working data collection from City-Data.com where we needed to three variables ('Median year house/condo built', 'Median household income', 'Median house or condo value' and 'Median resident age') for a few hundred zip codes as seen below.



There are several polygons that makeup a zip code, so an average value for all the variable is what we needed.

The raw data collected from the web page is like this:-
55388
2004
Median household income: $74,048
Median house or condo value: $158,600
Median resident age: 30.8
1976
Median household income: $74,583
Median house or condo value: $305,400
Median resident age: 48
1962
Median household income: $68,958
Median house or condo value: $218,900
Median resident age: 41.7
1994
Median household income: $58,587
Median house or condo value: $172,900
Median resident age: 39.5
1997
Median household income: $94,042
Median house or condo value: $233,300
Median resident age: 36.7
1986
Median household income: $138,917
Median house or condo value: $446,200
Median resident age: 39.9
2000
Median household income: $104,125
Median house or condo value: $263,800
Median resident age: 34.6

The expected output from above that will be used in excel average function is like this:-

55388
=AVERAGE(2004, 1976, 1962, 1994, 1997, 1986, 2000)
=AVERAGE(74048, 74583, 68958, 58587, 94042, 138917, 104125)
=AVERAGE(158600, 305400, 218900, 172900, 233300, 446200, 263800)
=AVERAGE(30.8, 48, 41.7, 39.5, 36.7, 39.9, 34.6)