Sunday, October 21, 2018

Accessing JSON nested object with python

This blog post highlights the key components to look at when parsing a JSON file with deep level of nested objects and variables.

First thing first, is to load in the file using: with statement...

The nested/child objects can then be accessed like this...
obj3['obj3a']['obj3a_1']['obj3a_2']['obj3a_3']... etc

Take this example, where we have a JSON object with parent object "requests" which contains "0" which also contains "responseCode" which also contains more children (in this case 3 children as seen above). Another child object at the same level with "responseCode" is "testPassFailCounts" which contains 217 more children.

That JSON structure is nested as follow:- requests >> 0 >> responseCode >> ... >> ... >> ... etc. Use a JSON viewer or reader such as JSON Editor Online to visualize the structural arrangement of your specific JSON file.

Now, to access any level of nested child in python follow this code snippet:-

import json

with open('name_of_file.json', encoding='utf-8') as f:
    data = json.load(f)
responseCode = data['requests'][0]['responseCode']
testPassFailCounts = data['requests'][0]['testPassFailCounts']

len(responseCode) # will return 3
len(testPassFailCounts) # will return 217

That is it!
Happy coding.

Tuesday, October 16, 2018

TkInter Open select file dialog windows from CMD

Are you writting a script for non tech savvy people that will require them to supply some file path like this: C:\Users\PC Name\Desktop\folder1\folder2\folder3\file-name.csv

As you already guess, many non-tech savvy individuals wont be able to type in such kind of file path to use you script. A work around this is to provide a Graphical User Interface (GUI) to the script, where is easier and user friendly to work with.

Here below is a simple solution using default GUI library that comes with python. This script gets an input file from user interactively via GUI, instead of using the CMD. It is written for both python 2 and 3:-

    # for Python2
    from Tkinter import *   ## notice capitalized T in Tkinter
    from tkFileDialog import askopenfilename

    polyfile1 = askopenfilename(title="Select original line file:", filetypes = (("comma-separated value (CSV) files","*.csv"),("all files","*.*"))) # show an "Open" dialog box and return the path to the selected file

    # Using the file...
    print ('Do something with the file in Py2', polyfile1)

except ImportError:
    # for Python3
    from tkinter import *   ## notice lowercase 't' in tkinter here
    from tkinter import filedialog

    polyfile1 = filedialog.askopenfilename(title="Select original line file:", filetypes = (("CSV files","*.csv"),("all files","*.*"))) # show an "Open" dialog box and return the path to the selected file

    # Using the file...
    print ('Do something with the file in Py3', polyfile1)

Running the script above should open the select file window as seen below.

That is enjoy the script.

Wednesday, October 10, 2018

How to Upload CSV file of Projected Local Coordinates onto ArcGIS Online

The cloud/web based version of ESRI ArcMap (ArcGIS Online) has come to stay. However, unlike the desktop version (ArcMap) that support many local coordinates systems, ArcGIS Online currently supports geographic coordinates in WGS84 but hardly reads local projected coordinates such as Nigeria Minna Datum UTM Zone 32N, StatePlane coordinates NAD 1983 (e.g StatePlane_Illinois_East epsg: 102671), Hong Kon 1980 Grid System, etc

If you try to upload such CSV file that have projected coordinates on "ArcGIS Online", you will encounter this error that says: "The layer was not created because no locations could be found. Make sure your data has valid location information".

The is because the coordinates in the CSV file are projected in UTM Zone 32 - Minna Datum (used in Nigeria region - EPSG: 26332).

Note: If you getting this required screen error: Location fields not fully specified. Then it means you did not select the correct location fields from the CSV file.

So, be sure to select the correct fields, that is Eastings for Longitude and Northings for Latitude.

If you are getting this error that says: "The layer was not created because no locations could be found. Make sure your data has valid location information", then you have to do one of the following to successfully upload you CSV data file.

Solution 1: Convert the projected coordinates to Geographical coordinates (that is convert from easting & northing to longitude & latitude).

Solution 2: Convert the CSV file itself to GeoJSON. The reason why this GeoJSON work even though the coordinates are still in projected form is because of the attribute or object in the GeoJSON file that defines the correct coordinates system that the coordinates represented.

Wednesday, October 3, 2018

The Basics of Map making With QGIS, GIMP and Inkscape

Making a modern print ready map will require one or both of the following, namely:
1) Scientific analysis
2) Art and design

In other words, the maps you see are both products of scientific charts as well as works of art and design.

GIS software such as QGIS does the science part better, illustration software such as GIMP and Inkscape handles the art part better.

If you are making a map to accurately/precisely visualize some variables based on scale, then you probably need a scientific map done with the QGIS/ArcGIS. If on the other hand, your map is simply to illustrate some variables not accurately/precisely to scale, then an illustration software like GIMP/Adobe Photoshop for raster editing or Inkscape/Adobe Illustrator for vector editing should be enough to get the job done.

With that said, it is a common practice these days to combine both the scientific and art & design software to finish a map layout. That is you will accurately prepare your map to scale in a scientific software and then complete the aesthetic layout using illustration software. Let's take a look at how this can be done below.

QGIS can handle the majority of vector and raster operations and most of the cartographic work. However, from a cartographic perspective, Inkscape and GIMP are primarily used to finish maps created within a GIS. Inkscape handles vector maps, while GIMP is best suited for raster maps. People often use GIMP to fine-tune coloration of a map. Inkscape is often used to add, for example, custom arrows to maps or add shadows to lines and polygons.

Basic Steps for making maps with QGIS, GIMP and Inkscape:-
1) Get the data
2) Load the data into QGIS
3) Symbolise and style the map according to the information the map wants to communicate
4) Prepare and compose it for printing
5) Export it as image for further fine-tuning in GIMP or export is as SVG file for fine-tuning in Inkscape

Note: If you need to have the map in print-ready magazines, brochures, posters, newsletters or other forms of page layouts and typographic quality text and images, then you will need use a desktop publishing application such as Scribus/Microsoft Publisher/Adobe Indesign or Pagemaker.

You should always bear in mind that QGIS understand all the science of map making which includes various GIS, Geodesic and Cartographic processes. GIMP, Inkscape and Scribus are there to support you in archiving a quality print/publish ready info-graphic maps.

Sunday, September 30, 2018

3 sure ways to Land your first GIS and Mapping Job - as a freelancer, contractor, or small business owner

Dear reader,

To effectively Build your career in this industry, you need a solid educational background by taking classes in geography, surveying, geodesy, cartography, GIS, spatial analysis, database management, web technologies, and programming. A common problem with GIS/digital map learning and related institutions is that they never guide you on how/where to find good paying jobs after they have impacted the necessary skills on you.

"It is one thing to acquire the skills and it is a different ball game to make money from your mapping skills".

Many classes in the formal education tend to focus more on the theoretical concepts, so I strongly encourage you to look on to acquiring production skills afterward. Learning platforms such Udemy, Lynda, Udacity, PluralSight, Boundless etc tend to have more practical and real-world production oriented courses. Take your time master those once that suit your career before jumping in the labor market.

In this post, I will open up your eyes to three ways to get your first GIS and Mapping Job. I assured you of your first GIS and Mapping Job or some passive income in three months time before settling on a permanent job, if you follow the advice below diligently... Let's do it.

Here are the three ways to land your first GIS and Mapping Job:-

1- Search and apply for opening in Government and Private sectors:
Note here, you should be able to accept or tolerate delay, problems, or suffering without becoming annoyed or anxious (it requires your maximum level patience).

There are many GIS entry-level jobs and internships often targeted at recent graduates. Many Government sectors at local, state or federal level have GIS/Mapping needs and this varies from one country to another. You will have to refer to your specific country to see what government organizations fits into your skills.

To give you some ideas, there are many different government industries that have GIS and mapping departments some of them include: health, agriculture, transportation, construction, real estate, mining, communication, disaster management, research institutes etc. Watch out for opening in some of these areas and push in when you find one.

On the other hand, there are privately run startups or companies you can work with. If you take away the big names, it is sometimes difficult to know what other options exist that you can apply to. Here I will show you how the search for them.
  • Conferences, meet-ups and workshops
  • Geospatial Magazines and other publications
  • GIS Forums
  • Subscribe to newsletters
As an example, below is newsletter from Geomares Publishing. Just that one newsletter alone, you already have access to so many potential employers of your GIS and mapping skills. There are all sort of information including job postings there to keep your eyes on for possible job openings.

The newsletter ofter covers the areas which include "Marine Product Updates, Geomatics Product Updates, GIM International Newsletter, Hydro International Newsletter, Offers and Promotions, Geomatics World Newsletter and GIS Professional Newsletter".

This is just one, there are many more magazine out there to subscribe to and get tones of current and relevant information in the GIS and Geospatial domain. Here is a list below, remember to search within your locality for local alternatives.

Most of these magazines are published few a times annually, but when they do get published be rest assure of finding ample of information including job listings and potential companies in the industry that could hire you.

I strongly encourage you subscribe at least to the soft copies if you can't afford the hard/printed copies and watch out for job openings.

Tuesday, September 25, 2018

QGIS 'Add Delimited Text Layer' with Special (Chinese Language) characters

Add Delimited Text Layer in QGIS isn't new. In fact it is the easiest way to import a list of coordinate points in .CSV file into QGIS as a map layer.

What is new here is that the CSV file has some columns with Chinese characters. And such characters are not well read in CSV file formats. For example here below is how the original data looks in excel .xlsx format.

After saving it as .csv for import into QGIS via "Add Delimited Text Layer" menu, it looks this below. Obviously this is not what is expected in the CSV file.

Excel (.xlsx) is not recognized in QGIS "Add Delimited Text Layer", so we can't use the excel file directly. We have to find a way for the CSV file to read the characters correctly or we look into using another file format such as the text file.

Sunday, September 16, 2018

Map of the Six Geopolitical Zone in Nigeria showing total number of registered voters

There are Six Geopolitical Zone in Nigeria as listed below. The six geopolitical zones of Nigeria is a major division in modern Nigeria, created during the regime of president General Sani Abacha. Nigerian economic, political and educational resources are often shared across the zones (source wikipedia).

North Central (loosely known as Middle Belt):

  • Benue
  • Kogi
  • Kwara
  • Nasarawa
  • Niger
  • Plateau
  • Federal Capital Territory

North East:

  • Adamawa
  • Bauchi
  • Borno
  • Gombe
  • Taraba
  • Yobe

North West:

  • Jigawa
  • Kaduna
  • Kano
  • Katsina
  • Kebbi
  • Sokoto
  • Zamfara

South East:

  • Abia
  • Anambra
  • Ebonyi
  • Enugu
  • Imo

South South:

  • Akwa Ibom
  • Cross River
  • Bayelsa
  • Rivers
  • Delta
  • Edo

South West:

  • Ekiti
  • Lagos
  • Ogun
  • Ondo
  • Osun
  • Oyo

Friday, September 14, 2018

Quick Python Guide to Extracting Data from API

Introduction to API
Many organizations uses the Application Program Interface (API) to allow developer access some of their data. Access to data set via API is usually controlled by using the "API Key or client ID" which can be obtain by registering for free or at some cost.

A data set that changes quickly is better served through an API instead of a static database. To access the API data you have to send request to the remote server where the data lives. In most cases, an API data lives on the remote server in XML or JSON format.

To learn more about specific API structure make sure you take a look at it's documentation which is usually made available by the provider. API
In this post, we will take a look at the open data on API. Specifically, we will send request to get the "players" data. The process discussed here will work for any request type with little or no modification.

First, before you continue I recommend you read the developer API page.

Step 1: Identify where the data lives and get its request url
From the request test page, you will that the players' data lives on this url below:-


Step 2: Get the url and parse it into python
Now that we know where the data we needed is located, we parse it into python. I prefer using JSON, so I will use the JSON url to collect the data into pandas data frame for further processing.

Note that you will need to identify the JSON element root and child to get hold of the data in pandas. To easily identify the element roots, use an online JSON reader such as this...

If everything was successful, the above script should produce the dataframe table below:-

Step 3: Do something useful with the dataframe data. You can save it to a database or CSV file.

That is it!

Sunday, September 2, 2018

Simple Map Animations using QGIS and GIMP

Hello there,
It is no longer new that most aesthetically pleasing maps out there have some of it elements accomplished with photo or graphics editing software.

In this post, you will see the important of having a graphics editing tool in your GIS tool set. We will use QGIS to generate the maps and then use GIMP to animate the maps for to present the map to our potential client.

Have a feel of what an animated map is below. It is the map of edo state, Nigeria displaying various levels of details on a single GIF image file.

Animated maps are good for showing time series data. Basically, this may involves illustrating the changing of same object over time in the same area or the simultaneous movement of different objects across an area over time.

Thursday, August 23, 2018

Cartographic Map Layout Designs


An important characteristic of maps is that they need to be both functional and aesthetically pleasing. Therefore, designing a quality map is more than just a scientific process, it takes your creativity, artistic and design skills to get the job done.

The craft of map making is called cartography, which is both the art and science of map making.

Well prepared map should contain the following elements on its map layout design:- map body, legend, title, north arrow (directional indicator), labels, scale, grid/graticule lines, citation, border and inset map.

Map Elements

1~ Map body: This is usually the largest element on a map layout. It is the primary focus on a map layout as it shows/display the geographical message and purpose of the map.

2~ Legend: This is the map element that lets the map reader know what each symbol on the map stands for. It help in understanding what information is been communicated on the map.

3~ Title: This is usually the largest text of the map and provides a short, descriptive, statement about the purpose of the map, and may include  other pertinent information, such as the timeframe for which the map applies.

4~ North arrow (directional indicator): This is the map element that tells the map reader the North, South, East and West directions on the map.

5~ Labels: These are textual elements written to further explain what an object is on the map. Most at time, map user will need explicit information apart from the on on the legend, so the "Labels" are there to help out. Often, it is in the attribute table of the features.

6~ Scale: This is the ratio of measurements on the map to that on the true ground. It is usually displayed in linear graphic or written text.

7~ Grid/Graticule lines: There are references a coordinate, or measurement system, that the map user can use to derive the location, coordinates.

8~ Citation: This is also know as "Metadata". It is the documentation for the map and the data displayed on the map. Metadata should include items such as the date the map was created, the author of the map, and data sources for the data shown on the map body.

9~ Border/Neat line: This is a frame for the map which typically surrounds the entire map. It separate the map from the surrounding page or elements.

10~ Inset map: This is a smaller map body that shows from which the main map body was extracted from. It help in making sense of where the main map is located especially for unfamiliar maps.

Sunday, August 19, 2018

Transforming Nigeria Minna Coordinates (epsg: 4263) to WGS 84 (epsg: 4326) using QGIS


Different countries have different local coordinate geographic reference systems (CRS), Nigeria is not an exception. One of the most developed and used local geographic CRS in Nigeria for general mapping is the "Minna  (epsg: 4263)".

EPSG - "European Petroleum Survey Group" is the organization in charge of maintaining different datum, coordinate reference systems and coordinate transformations around the world which may be global, regional, national or local in application. It is also worthy to know that the organization is also called: "International Association of Oil and Gas Producers" (IOGP).

A search on for "Minna" reveals both geodetic and projected CRS. Our focus in this article is on the newest Minna geodetic (geographic) datum with EPSG code 4263, that has it measuring units in degrees as seen below.

Note that there is a deprecated version of the Minna datum with EPSG code as: 62636405

"Minna" geodetic datum was first derived from the "Nigerian National Coordinates System" which is no longer in use. "Minna" geodetic datum is suitable for use in Nigeria - onshore and offshore. "Minna" references the Clarke 1880 (RGS) ellipsoid and the Greenwich prime meridian. Minna origin is Fundamental point: Minna base station L40. Latitude: 9°38'08.87"N, longitude: 6°30'58.76"E (of Greenwich). Minna is a geodetic datum for Topographic mapping.

It has the following Extent: 2.66°E, 1.92°E, 14.65°N, 13.90°N (upper long., lower long., upper lat., lower lat.).

Friday, August 10, 2018

Getting Google Maps API key in 2018

If you are an old developer who uses the Google Cloud Platform Console developer's tools such Google Maps API key to power application, you will notice that getting a copy of the maps API key has slightly changed in the month of July, year 2018.

Unlike in previous years, when signing up for a copy of the key is just a matter of having a Google account and then putting up a simple request. Today, Google do request for credit card information before the sign-up process is completed. So, the big question now is: Is there no more FREE quota for the Google Maps API key anymore?

Creating a Google Maps API Key
Even though, Google now requests for your credit card information before the sign-up for a key there is still the free quota usage on the API key as usual. Google says: the reason why it request for the credit card information before the sign-up, is to make sure bots/robots don't sign-up for the keys. Also, there is no auto charge on your card when you use up the free trial/quota on your key.

Before you are charged, you will have to manually upgrade your key to a paid plan.

Saturday, July 28, 2018

How to Extract Accurate Point Coordinates and Heights from Google Earth

In this post, we will use free software to extract height/elevation/altitude of points above sea level for any location in the world from DEM (digital elevation model) databases. This is fairly good data for drawing contour maps, draw a profile of a track or to colorize points by height above sea level.

The sources of the elevation data is from a DEM (digital elevation model) databases as explained below:-

DEM data sources
USGS: NED The U.S. Geological Survey's excellent National Elevation Dataset covers the United States, Canada, and Mexico. 1 arc-second (~30-meter) horizontal resolution is available in most areas (NED1). For Alaska, 60-meter data is also available (NED2). 
NASA: SRTM1 NASA's SRTM1 database (from the Space Shuttle Radar Topography Mission) has a resolution of about 30 meters. Previously, SRTM1 data was only available for the United States (and was not very useful because NED1 is generally better), but recently NASA has released SRTM1 tiles for the entire world. GPS Visualizer's server does not contain the full global dataset, but it does contain all of Europe, Japan, South Korea, and Taiwan, as well as parts of Australia, New Zealand, and South Africa. Additional locations will be installed upon request. 
ASTER: The ASTER GDEM is a joint product of NASA and the Japanese Ministry of Economy, Trade, and Industry (METI). ASTER has very good 30-meter coverage of the entire world, but the awkward download process and the massive size of the database make it impractical to store all of it on ASTER files for Iceland are available, however, since none of the other 30-meter databases cover that area. (As with SRTM1 data, additional files can be added upon request.) 
NASA: SRTM3 NASA's SRTM3 dataset includes 90-meter resolution for the entire world.

Monday, July 23, 2018

GIS Base map with Web Map Service (WMS)

Web Map Service (WMS) is a convenient way for an organization to publish or share spatial datasets online that can be readily used in GIS. WMS is a popular standard for publishing maps on the internet.

WMS is hosted on a remote server. Similar to a website, you can access it as long as you have a connection to the server. WMS is a standard protocol that serves geo-referenced map images using data from a GIS database.

With WMS you have access to a live service that will automatically refresh its view if you pan or zoom on the map. So, you always have access to the latest and upto date published data.

WMS are perfectly use as background maps for GIS project. It can be used on web, mobile and desktop GIS applications. All you need is the WMS getURL (GetMap or GetCapabilities) from any of the organizations that publish or share spatial datasets online.

Some WMS organizations are:-
1~ USGS:
2~ Boundless Geo:
3~ Mundialis:
4~ Terrestris:
5~ Geofabrik:
6~ The Hug:
7~ Omniscale:
8~ WhereGroup:
9~ Sinica:

Friday, July 20, 2018

Difference between GeoJSON and TopoJSON

In the Geospatial industry, data handling and conversion is a vital skill especially when data are been moved from on platform to another.

Some data formats work better on one platform than another. For example, data in shapefile format are more flexible on desktop apps than on web apps. If you are looking for an excellent data format to use on the web, then "GeoJSON and TopoJSON" data formats are your best option. But what is the difference between "GeoJSON and TopoJSON"?

In this post, I will attempt to differentiate the two powerful web based geospatial data formats (GeoJSON and TopoJSON).

GeoJSON is an open standard format designed for representing simple geographical features, along with their non-spatial attributes. Both GeoJSON and TopoJSON are based on JSON, the JavaScript Object Notation.

As extracts from Noah Veltman of and Mike Bostock (and other contributors to the TopoJSON extension) repectively:-

GeoJSON and TopoJSON are two web-friendly file formats for geographic data.
A GeoJSON file is a text file with a list of features and, for each one, a bunch of latitudes and longitudes describing its geometry.
A TopoJSON file is similar, but instead of storing the latitudes and longitudes directly, it describes the topology (geometrical properties and spatial relations of figures) of a group of features, meaning the borders between them. TopoJSON files are usually much smaller, but require a little bit of extra processing in the browser when you want to display one on a map, and can potentially lose details from the original latitudes/longitudes.

TopoJSON is an extension of GeoJSON that encodes topology. Rather than representing geometries discretely, geometries in TopoJSON files are stitched together from shared line segments called arcs. TopoJSON eliminates redundancy, offering much more compact representations of geometry than with GeoJSON; typical TopoJSON files are 80% smaller than their GeoJSON equivalents. In addition, TopoJSON facilitates applications that use topology, such as topology-preserving shape simplification, automatic map coloring, and cartograms.

The advantage of TopoJSON over GeoJSON is size and encoding of topology. So, if the file size or topology of feature is paramount to you, use TopoJSON instead of GeoJSON.

Monday, July 16, 2018

Map of 2018 Ekiti State Gubernatorial Election Final Result

The much anticipated 2018 Ekiti state gubernatorial election has come to pass and 24 hours after the result has been announced by INEC, Nigeria social and news medias are flooded with the result.

Unfortunately, non has analysed the result on a map. In this post, I will related the result to map of Ekiti state so we can see the spatial relationship in the result.

Ekiti state has 16 local governments and 177 electoral wards.

Thursday, July 12, 2018

Geo-visualization of FIFA 2018 World Cup

As stated on Wikipedia page: The 2018 FIFA World Cup is the 21st FIFA World Cup, a quadrennial international football tournament contested by the men's national teams of the member associations of FIFA. It is currently ongoing in Russia starting from 14 June and will end with the final match on 15 July 2018.

In this post, I will attempt to visualize the participants on a world map starting from qualifying countries, group stage, round of 16, quarter finals, semi finals etc.

Let's get started....

Saturday, July 7, 2018

Python and Data Science Blogs

The list below are some of my favorite blogs I have followed and gained alot of from over the years. I hope you will also like them.

Some useful blogs for python and data science enthusiasts:-
















Wednesday, July 4, 2018

Geo-spatial Professional Areas of Interests

The Geospatial industry is quite a vast industry that encompasses many areas of interest. In this article, I will briefly take a look at the most common areas.

As someone who works in the Geospatial industry, you will find yourself doing one or more combinations of this areas of interests:-

Tuesday, June 12, 2018

Modern Map of Ancient Kano City Gates (Kofa)

Kano City Gates - Kofofin Garin Kano

The amazing structure (the ancient walls of Kano city, Nigeria) was built during the reign of King Kijimazu (Sarki Gijimasu) between 1095 through 1134 and completed in the middle of the 14th century. They are ancient defensive walls built to protect the inhabitants of the ancient city of Kano and were described as "'the most impressive monument in West Africa".

Below is a copy of a Map produce in 2004 by 'Geography Dept, Bayero University, Kano (BUK)' showing the accient Wall and Gates.

The ancient wall is a 14km radius earth structure that surrounds the Dala Hills, Kurmi Market and Emir's Palace located in the heart of the modern day city of Kano as seen as the darkest spot on the map below.

The Ancient Kano City Walls originally had an estimated height of 30 to 50ft and about 40ft thick at the base with 15 gates (kofa) around it.

The names of the gates are:-
1~ Kofar Kansakali
2~ Kofar Kabuga
3~ Kofar Gadonkaya
4~ Kofar Dukawuya
5~ Kofar Waika/Adama
6~ Kofar Wambai
7~ Kofar Mazugal
8~ Kofar Mata
9~ Kofar Nassrawa
10~ Kofar Dan Agundi
11~ Kofar Na'isa
12~ Kofar Ruwa
13~ Kofar Fampo
14~ Sabuwar Kofa
15~ Kofar Dawanau

In todays modern Kano city, the gates are all that is left. Ninety percent of the walls have since disappeared, they are either gone or crumbling, very soon there will be nothing left of it and history of the walls would be erased completely.

Most of the gates have been rehabilitated and rebuild by the past Kano state government.

Adeyemi and Bappah coducted field survey in 2010 and obtained the following "Summary of Wall Measurements and Observations" below as published in their research paper.

Source: Conservation of Kano Ancient City Wall and Gates: Problems and Prospects in Nigeria, (2010)

Saturday, June 9, 2018

Street-level Map of Nigeria Cities

Most at time it is almost impossible to find an updated and editable version of Nigeria city map at street-level that shows details such: Buildings, Landuse, Natural features, Places, Places of worships, Railways, Roads/Streets, Traffic, Transport stations, Waterways etc.

Such detailed maps are great for many task including for city planning. In this post, I present to you a street-level map data at scale for all major cities in the country.

Lagos City, Lagos (State) - Badagry, Epe, Ikeja, Ikorodu, Lagos, Mushin, Shomolu

Eastern Cities, Enugu (State) - Enugu, Nsukka | Anambra (State) - Awka, Onitsha | Imo (State) - Owerri | Abia (State) - Aba, Arochukwu, Umuahia

Friday, June 8, 2018

Unable to parse KML file in python 3 with PyKML module


Recently, I picked up a project where I had to read/parse in a point KML file and do reverse geocoding on the latitudes and longitudes coordinates of the points. So, I found a nice python module that will help me accomplish this. But I found out that it doesn't work fine on python 3 installation but works great on python 2.

When I import pyKML as follow "from pykml import parser" in python3, it returns the error as thus: ModuleNotFoundError: No module named 'urllib2'

I knew the pyKML module was trying to work with 'urllib2' module which has changed in python3. Since python2 will soon be discontinued, I have to find a solution for it to work on python3.

Ok, just in case you don't know pyKML, according to the documentation, pyKML is a Python package for creating, parsing, manipulating, and validating KML documents/files. A KML is language for encoding and annotating geographic data used by Google Earth, Google Maps and a number of other GIS platforms.

Tuesday, May 29, 2018

Find the Elevation of any Location

According to WikiPedia: the elevation of a geographic location is its height above or below a fixed reference point, most commonly a reference geoid, a mathematical model of the Earth's sea level as an equipotential gravitational surface.

In the geo-spatial industry, getting and working with the elevations of points is a very common task for many obvious reasons. Elevation value of points can be obtained through various techniques such as land surveying and GPS observations.

Using the techniques above, there will be a challenge when you need to obtain the points that are difficult to access. In such situations, you will have to consider a remote service to get such elevation values. One of such remote services that provide access to elevation data we will discuss in this blog post is:

Tuesday, May 22, 2018

Jupyter Notebook Python user input() function

Jupyter notebook has added a feature I have always wished it had long ago. Before now, writing a script that accepts input from user with the input() function in python3 or raw_ input() function in python2 was almost impossible and you have to switch between the terminal window and the jupyter notebook all the time.

The newer version of jupyter notebook has made available a text-box right inside the browser whenever you call the input() function as seen below;-

Enjoy the new GUI feature of the jupyter notebook.

Wednesday, April 11, 2018

Scrape data from Google maps

Scrapping data from Google maps made by third party

Often, you will find Google maps published by someone you don't have access to and you really want to extract some data from the map.

Lets consider this map below, assuming it was published by someone you don't know and you have to have access to the raw data behind the map.

When you click on individual features on the map, the required data of that point is displayed on the left side panel. Now, the task is to extract or collect those data for every point feature on the map into a spreadsheet for further use/consumption.

Step to extract the data

Here is how to go about extracting such dataset.

Step 1: On the main page, click on the three vertical dots to expand the menu

Step 2: Select "Download KML" to download a file that can be read by Google Earth software, text editor and other GIS software.

Step 3: Open this downloaded KML file in any software of your choice to access the data contained there in. In my case, I used QGIS to open the kml file and exported the content into a CSV/Excel spreadsheet.

That is it!
Now if you come across any Google maps that you want to access the data used in preparing the map, that is how to go about accessing it. Enjoy!

Sunday, April 8, 2018

GPS coordinates of INEC Offices across the country

Find GPS coordinates of INEC Offices in Nigeria

Few days ago, I wrote on finding addresses of INEC states' offices. I even showed the locations of each INEC state headquarters on Google maps.

On this post, you will find list of Latitude and Longitude GPS coordinates of INEC offices across the country. There is at least on major office in each state of the federation, here is the list below:-

INEC Abia Hqtr, Umuahia
INEC Adamawa Hqtr, Jimeta
INEC Akwa-Ibom Hqtr, Calabar
INEC Anambara Hqtr, Awka
INEC Bauchi Hqtr, Bauchi
INEC Benue Hqtr, Makurdi
INEC Borno Hqtr, Maiduguri
INEC Bayelsa Hqtr, Yenagoa
INEC Cross-River Hqtr, Calabar
INEC Delta Hqtr, Asaba
INEC Ebonyi Hqtr, Abakaliki
INEC Edo Hqtr, Benin City
INEC Ekiti Hqtr, Ekiti
INEC Enugu Hqtr, Enugu
INEC Nigeria Hqtr, Abuja
INEC Gombe Hqtr, Gombe
INEC Imo Hqtr, Owerri
INEC Jigawa Hqtr, Dutse
INEC Kebbi Hqtr, Birnin Kebbi
INEC Kaduna Hqtr, Kaduna
INEC Kogi Hqtr, Lokoja
INEC Kano Hqtr, Kano
INEC Katsina Hqtr, Katsina
INEC Kwara Hqtr, Ilorin
INEC Lagos Hqtr, Lagos
INEC Niger Hqtr, Minna
INEC Nasarawa Hqtr, Lafia
INEC Ondo Hqtr, Alagbaka
INEC Ogun Hqtr, Abeokuta
INEC Osun Hqtr, Osogbo
INEC Oyo Hqtr, Ibadan
INEC Plateau Hqtr, Jos
INEC Rivers Hqtr, Port Harcourt
INEC Sokoto Hqtr, Sokoto
INEC Taraba Hqtr, Jalingo
INEC Yobe Hqtr, Damaturu
INEC Zamfara Hqtr, Gusau

If you find any inconsistent or missing data, please let me know to correct immediately at: umaryusuf49 (at)

Thank you for following.