Monday, January 14, 2019

Python Programming for GIS Data Processing in QGIS

Python is a general purpose programming language that has a strong presence in the GIS industry as many house hold software such as ArcGIS and QGIS do expose their interfaces through python scripting.

Broadly speaking, python can be used for any of the following:-
1~ Scripting and Automation
2~ Web Development
3~ Data Science — including Machine Learning, Deep Learning, Data Analysis, and Data Visualization
4~ Embedded Applications - Hardware Programming
5~ Gaming
6~ Desktop Applications
7~ Network Programming

Here our focus will be to use python to automate GIS processes via well packaged video series as seen below. Python is excellent tool for doing GIS data wrangling, data manipulation and analysis processes. That is exactly what I set out to teach you in this video series.... Let's get our hand dirty manipulating GIS data with python starting with the basics off cause 😊.

Video 1: Getting Started Setting up working environment

Video 2: Writing and executing code

Video 3: How to Install Third-party Python Modules in QGIS 3.x

Video 4: Python Implementations, Comment, Variable, Interactive Help

Video 5: Python Data Types - Part 1

Video 6: Python Data Types - Part 2

Coming soon...
Video 7: Python Data Types - Part 3

Coming soon...

Saturday, January 12, 2019

How to Prepare A Site Plan

Before we see "How to a Site Plan can be Prepared", here is a little background to what it is.

Who is a Land Surveyor?
A land surveyor is person who is trained and licensed by a regulatory body to practice legal survey profession in a state. This person will be under the supervision of the state's surveyor general or the director/commissioner of surveys for that state.

One important document produced by land surveyors is the site plan (also called survey plan or professional survey or boundary survey or lot description or final survey or parcel demarcation etc).

What is a Site Plan?
A Site Plan is a graphical description of a parcel of land that is attached to the application of Right of Occupancy (RofO) or Certificate of Occupancy (CofO) over a landed property. It is a necessary legal document required by the authority to approve the development of a land parcel. It is a document that measures the boundary of a parcel of land. It gives an accurate measurement, description of the piece of land.

Information to be Shown on a Site Plan
A professional site plan drawn to scale should show the entire property (including all property lines) with the existing and proposed structures. Other information that must be shown include:
~ the name of the owner of the land surveyed
~ the address or description
~ the size and the drawn-out portion as mapped out on the survey plan document
~ the beacon numbers
~ the name of the Surveyor who drew up the survey plan
~ the date it was drawn and a stamp showing that the land is either free from government acquisition or not
~ the directional arrow (aka North Arrow)
~ the Scale at which the plan was drawn
~ the coordinates system used
~ the reference control beacons used

Why is a Site Plan Required?
The primary reason why a site plan is required is to get what is known as a "Land Information". Before a transaction is consummated over a plot of land, it is always advisable to prepare the site plan presented for the land to basically find out whether it falls under government acquisition or not and as well authenticate the claim of ownership to the land.
In the case of a new construction, building additions, substantial accessory structures, and parking must be submitted on a professional stamped survey. Land authorities will make the final determination whether your project met the requirements to be implemented on that land.

Can I Draw the Site Plan Myself?
Yes, if you have the skills to do it. However, if the purpose of the plan is for legal documentation a registered surveyor most endorses your work to be considered by any authority.

How to Prepare A Site Plan

You don’t have to be a genius to prepare a site plan, but you do have to be able to work with the tools that helps you collect data from site and draw them on a paper.

Basically, there are two phases to producing a site plan namely:-

Phase 1: Site work
Here is where the surveyor goes to the field for the purpose of data collection. Depending on the purpose and the accuracy of the survey plan, different kind of instruments are used for the site data collection. These instruments include:-
a) Chain instrument
b) Compass
c) Theodolite
d) Total station
e) GPS

Whatever the instrument used, you will collect data such as distance, bearings and coordinates that will be used to draw the survey plan in the next phase.

Phase 2: Office Work
This is where you do the actual drawing of the survey plan. There are different kind of instruments used for plotting/charting survey plan, however the most commonly use software is the AutoCAD drafting software.

Learn to draw/plot survey plans using a FREE software similar to AutoCAD from here.

Thank you for reading.

Saturday, December 22, 2018

Install Third-party Python Modules in QGIS 3.x on Windows 10 platform

Here is how you can install third-party Python Modules in QGIS 3.x on Windows 10 platform. First let's see one very important module that is not installed with python setup that comes with QGIS. This module we will look at is "Pandas".

If you launch QGIS Python Console, and import 'pandas', you will get error

Steps to solving the problem

Step 1: Search for "OSGeo4W Shell"

Step 2: Right click on it and select "Run a s Administrator"

Step 3: Ensure you can run pip from the command line. You may encounter error that says: No module named pip

In my case I ran python -m ensurepip --default-pip to get pip working. You can learn more from the link above. The "-m" flag import the ensurepip module or package and then run as a script.

Note: If you want to switch the shell from python 2.7 to python 3.x, simply enter this command: py3_env. I will advice you do that because that is what the QGIS 3.x python console is using by default. So, just enter py3_env to switch to python 3 shell, then install your third-party modules there.

Step 4: Run: python -m pip install pandas to get pandas module installed as seen above.
Now you can import and use pandas in QGIS Python Console for further data manipulation without any error as seen below. The "-m" flag import the pip module or package and then run as a script.

That is it!

A video explanation of the steps above is here below:-

Tuesday, December 11, 2018

How to save High Resolution Image from Google Earth Pro

I have seen many "Google Earth Pro" users taking screenshots of the images instead of saving it directly in high resolution, probably because the "Save Image" function is a little bit obscured. This post will guide you through saving a high resolution image from "Google Earth Pro" released in the year 2018.

At first when you click on the save button, nothing seems to happen aside the "Untitled Map", "Compass", "Scale" and empty "Legend" boxes that pop-up on the screen.

If you look closely, just under the "Untitled Map" box, there appear the "Save Image" tool bar. On that very tool bar, you will see the "Save Image" button. That is the button you actually needed to save the image.

But before you save your image, you will definitely like to update the map title and do other settings. This can be done from the "Map Options" button on the "Save Image" tool bar.

You could also select your preferred image resolution from the tool bar.

Thank you for reading.

Tuesday, December 4, 2018

An Atlas Map of Nigerian States - QGIS Map Report Tutorial

QGIS 3 comes with a nice feature for creating collection of maps (aka Atlas). This feature is called "Report" in QGIS 3, it works closely like the "Print Layout" (formerly know as "Print Composer" in QGIS 2).

You can access the "Report" window from the project menu as seen below...

In the next few lines, I will demonstrate how to generate a map report in QGIS using the Map of Nigerian States. See the document we want to produce at the end of this tutorial here...

Saturday, December 1, 2018

The Difference between the United Kingdom, Great Britain and England

Often people confuse these three: United Kingdom, Great Britain and England. As an example, in sports different names are used for Olympic games different from football World Cup game and many others.

Below is the map of the world and the area in question is this tiny mass of land within the red mark.

Lets zoom in and look at the map closer, the whole of that area is the "British Isles" consisting of five countries which is categorized into to named: Ireland and Great Britain.

Ireland consist of two countries "Republic of Ireland and Northern Ireland", while Great Britain consist of three countries "England, Scotland and Wales".

United Kingdom is made up off the whole of Great Britain and part of Ireland. That is all the countries in Great Britain ("England, Scotland and Wales") are in United Kingdom and in Ireland only Northern Ireland is part, Republic of Ireland isn't part of United Kingdom.

Hmm! This sounds complicated, right? Let clarify this by visualizing it on a map.

British Isles = Ireland + Great Britain

Here purple color for Ireland and blue color for Great Britain to clearly see to two different regions.

Ireland = "Republic of Ireland + Northern Ireland"
Great Britain = "England + Scotland + Wales"

United Kingdom =  "England + Scotland + Wales + Northern Ireland"

I hope that was clear and succinct.
Thank you for reading

Wednesday, November 14, 2018

Drawing Site Plan with DraftSight a FREE Alternative to AutoCAD

There are many low budget or free Computer-Aided Design (CAD) software alternatives to Autodesk's AutoCAD out there and DraftSight is one of the best alternatives I have used.

Using the free version, you could plot or draw a professional survey plan just as you would do in AutoCAD. In this blog post, I will demonstrate how you will do just that using the free DraftSight CAD software. So, download the DraftSight here and follow the instructions below to activate it.

Instruction 1: Download the software from the link above and launch it to install

Instruction 2: Select Free option and click the next button as seen above.

Instruction 3: Accept the terms in the license agreement and install

Tuesday, November 13, 2018

The difference between "Geocoding" and "Geolocation"

These two terms are often confused by users in of spatial data. Here is a quick explanation to help clarify the difference between the two. Both of these terms are consistently been misuse by people within the geospatial community.

Address: "Abuja International Conference Centre, Herbert Macaulay Way, Abuja, Nigeria"
Coordinates (in 3D): "Latitude: 9.0438014, Longitude: 7.4919024, Sea level: 503m"

Looking at the landmark address above and its corresponding coordinates in three-dimension (3D), we could say:-

Geocoding - means to 'Convert addresses to geographic coordinates, or the reverse'. While  Geolocation - means to 'Return the precise location of a device based on Wi-Fi or cell towers'.

More elaburate explanation from Wikipedia, the free encyclopedia:-

Geocoding is the computational process of transforming a physical address description to a location on the Earth's surface (spatial representation in numerical coordinates). Reverse geocoding, on the other hand, converts geographic coordinates to a description of a location, usually the name of a place or an addressable location. Geocoding relies on a computer representation of address points, the street / road network, together with postal and administrative boundaries.

Geolocation is the identification or estimation of the real-world geographic location of an object, such as a radar source, mobile phone, or Internet-connected computer terminal. In its simplest form geolocation involves the generation of a set of geographic coordinates and is closely related to the use of positioning systems, but its usefulness is enhanced by the use of these coordinates to determine a meaningful location, such as a street address.

Sunday, November 4, 2018

Installed Python Libraries on QGIS Vs Anaconda

As some one who uses Python for Geospatial development, I was tempted to know what modules are installed on QGIS python environment compared to that of Anaconda python.

On the console of the two platforms, I executed this: help('modules') and I got the following out puts.


MetaSearch console mkgraticule sre_parse
PyQt5 contextlib mmap ssl
__future__ copy mmapfile sspi
_ast copyreg mmsystem sspicon
_asyncio crypt mock stat
_bisect csv modulefinder statistics
_blake2 ctypes msilib string
_bootlocale curses msvcrt stringprep
_bz2 cycler multiprocessing struct
_codecs datetime nbformat subprocess
_codecs_cn dateutil netbios sunau
_codecs_hk db_manager netrc symbol
_codecs_iso2022 dbi networkx symtable
_codecs_jp dbm nntplib sys
_codecs_kr dde nose2 sysconfig
_codecs_tw decimal nt tabnanny
_collections decorator ntpath tarfile
_collections_abc difflib ntsecuritycon telnetlib
_compat_pickle dis nturl2path tempfile
_compression distutils numbers textwrap
_csv doctest numpy this
_ctypes dummy_threading odbc threading
_datetime easy_install ogr time
_decimal email ogrmerge timeit
_dummy_thread encodings opcode timer
_elementtree ensurepip operator token
_functools enum optparse tokenize
_hashlib epsg_tr os trace
_heapq errno osgeo traceback
_imp esri2wkt osr tracemalloc
_io exifread owslib traitlets
_json expressions parser tty
_locale faulthandler past turtle
_lsprof filecmp pathlib types
_lzma fileinput pbr typing
_markupbase fnmatch pct2rgb unicodedata
_md5 formatter pdb unittest
_msi fractions perfmon urllib
_multibytecodec ftplib pickle urllib3
_multiprocessing functools pickletools uu
_opcode future pip uuid
_operator gc pipes venv
_osx_support gcps2vec pkg_resources warnings
_overlapped gcps2wld pkgutil wave
_pickle gdal platform weakref
_pydecimal gdal2tiles plistlib webbrowser
_pyio gdal2xyz plotly win2kras
_random gdal_auth poplib win32api
_sha1 gdal_calc posixpath win32clipboard
_sha256 gdal_edit pprint win32com
_sha3 gdal_fillnodata processing win32con
_sha512 gdal_merge profile win32console
_signal gdal_pansharpen pstats win32cred
_sitebuiltins gdal_polygonize psycopg2 win32crypt
_socket gdal_proximity pty win32cryptcon
_sqlite3 gdal_retile py_compile win32event
_sre gdal_sieve pyclbr win32evtlog
_ssl gdalchksum pydoc win32evtlogutil
_stat gdalcompare pydoc_data win32file
_string gdalconst pyexpat win32gui
_strptime gdalident pygments win32gui_struct
_struct gdalimport pylab win32help
_symtable gdalmove pyodbc win32inet
_thread gdalnumeric pyparsing win32inetcon
_threading_local genericpath pyplugin_installer win32job
_tracemalloc getopt pyproj win32lz
_warnings getpass pythoncom win32net
_weakref gettext pytz win32netcon
_weakrefset glob pywin win32pdh
_win32sysloader gnm pywin32_testutil win32pdhquery
_winapi gzip pywintypes win32pdhutil
_winxptheme hashlib qgis win32pipe
abc heapq queue win32print
adodbapi hmac quopri win32process
afxres html random win32profile
aifc http rasutil win32ras
antigravity httplib2 re win32rcparser
argparse idna regcheck win32security
array imaplib regutil win32service
ast imghdr reprlib win32serviceutil
asynchat imp requests win32timezone
asyncio importlib rgb2pct win32trace
asyncore inspect rlcompleter win32traceutil
atexit io runpy win32transaction
audioop ipaddress sched win32ts
base64 ipython_genutils scipy win32ui
bdb isapi secrets win32uiole
binascii itertools select win32verstamp
binhex jinja2 selectors win32wnet
bisect json servicemanager winerror
builtins jsonschema setuptools winioctlcon
bz2 jupyter shapely winnt
cProfile jupyter_core shelve winperf
calendar keyword shlex winreg
certifi lib2to3 shutil winsound
cgi libfuturize signal winxpgui
cgitb libpasteurize simplejson winxptheme
chardet linecache sip wsgiref
chunk locale sipconfig xdrlib
cmath logging sipdistutils xlrd
cmd lzma site xlwt
code macpath six xml
codecs macurl2path smtpd xmlrpc
codeop mailbox smtplib xxsubtype
collections mailcap sndhdr yaml
colorsys markupsafe socket zipapp
commctrl marshal socketserver zipfile
compileall math sqlite3 zipimport
concurrent matplotlib sre_compile zlib
configparser mimetypes sre_constants

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.