This is the second part in working with the HCMGIS QGIS Desktop plugin that is rich with functionalities and to check out the first part of thewalkthrough click the link shown Working with HCMGIS QGIS Plugin Part 1
The walkthrough continues below with more functionalities.
Download Covid-19 Data
The third tool is for downloading Covid-19 data which can be used to create heatmaps showing and performing analysis on data with respect to covid-19. Click on Download Covid-19 Data shortcut under it select the first submenu shortcut as shown below.
This downloads and displays covid-19 data from the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University Hopkins data repository. The downloaded data appears as shown below in QGIS Desktop map canvas.
The map below shows covid-19 data for African countries with each dot representing country or sovereignty.
Below is the attribute table for the covid-19 point layer. Note the Country_Region column containing names of countries.
While still in the attribute table, identify and click on the icon on top of the attribute data that contains an epsilon label as shown below.
This opens selection window which will be used to demonstrate selection in QGIS Desktop by use of expression. For details on QGIS expressions refer to the QGIS Documentation.
The intention here is to select points representing countries with covid-19 cases that are beyond a given value. The first step will be to identify the field/column that contains the value of our interest. In this case identify the Fields and Values and double click to collapse it and select Active by double clicking on it as well.
Note that the double clicked field name will appear in the left text area containing double quotes. Note that all fields in QGIS expressions are represented like the one shown below. Add a greater than sign ‘>’ as shown below and add a value like 100000 as shown below.
Ensure that the expression window’s bottom left area is clear of any errors that can be indicated in red and then click Select Features button at the bottom right area of the window.
If the attribute table had been closed, open it and the selected fields will appear as shown below.
Similarly in the map, some of the points have been selected (in yellow) and represent countries that have active cases of over 100000.
In summary, we have been able to visualize covid-19 data using HCMGIS plugin and filtered the data to select only countries that have over 100000 active covid-19 cases. This is a case example among others that HCMGIS plugin can be used.
Download Open Data
Browsing for GIS data online, identifying it, downloading and extracting it can be time consuming and at times exhausting. HCMGIS plugin’s Download OpenData functionality can save some time on this and also provide up-to-date data for those repositories that update their data.
To download data from geofabrik, click on the first option under Download OpenData shortcut labelled OSM Data ye Country from Geofabrik. Geofabrik, as explained in a recent post on downloading geospatial data is an open street map data repository through which one can download data from.
On clicking the shortcut a windows is displayed and appears as shown below. It contains various controls for selection and buttons.
Click on the first drop down that contains representation of world regions. For this case, Africa region would suffice otherwise any other region can be selected.
The next step entails selecting a country within Africa region selected above. Sao Tome and Principe is the selected country as shown below. Note that different countries have different sizes of datasets and the bigger the data, the more the time it will take to download the data.
Use the browse button labelled … to navigate to he folder where the downloaded data will be saved. Select a suitable location in the local computer. A message will show informing on the size of data to be downloaded and that it may take time. The message is as shown below.
Once the download is complete, the download progress bar will be full and at 100% as shown below.
After download a success message will be shown as well indicating that the download has been completed successfully.
The downloaded data will automatically be loaded in the QGIS Desktop layers panel and in the map canvas as shown below. for Sao Tome and Principe.
Similar to previous steps, the attribute table of the data can also be opened and for this case, the attribute table appears as shown below.
In summary, HCMGIS plugin can be leveraged to download data from Geofabrik, an Open Street Map data repository o-the-fly into the machine and visualized.
Download GADM data
The other open data download supported include data from Global ADMinistrative areas repository which can be accessed from this link.
Click on the shortcut shown below to download data from GADM repository.
A window containing download options in controls appears as shown below. To begin, click on country drop down.
The drop down shows list of all countries in the world. Select your preferred country as in this case, the selected country is Kenya. as shown below.
A message showing the shapefile size to be downloaded and informs that the download may take time. Click Yes button to continue.
Once the download has started, the progress bar starts to change by increasing percentage value as the download continues in the background. Once the download has completed, the progress bar is at 100%.
A message is shown once the download is complete informing that the download process has completed successfully or with error. Click OK button to continue.
Another message similar to the messages above shows informing that the extraction of the data has completed successfully. Click OK to proceed.
The downloaded data is displayed in the QGIS map canvas and has several administrative levels. The one shown below is the administrative level zero of the whole country. Note that in the Layers panel there are four layers representing the administrative levels.
Disable all the layers by unchecking the checkboxes in the Layers panel except for the layer labelled gadm36_KEN_1 which will be shown in the map canvas as below. This is the administrative level 1 representing the counties of Kenya.
To view the attribute table right click on the active (checked) layer and click Open Attribute Data option shown below.
The attribute table for the layer will be displayed and appears as shown below.
In summary, the plugin saves the time that would take to navigate to download page using browser to download like in a previous procedure and also extracts and visualizes the data in QGIS Desktop.
Building Footprints from Microsoft
HCMGIS plugin supports spatial dataset download from Microsoft Building footprints data repository. The repository can be accessed through their GitHub repository. To access the functionality, click on the shortcut as shown below.
A window containing controls for country, province/state, file size and number of buildings among others appears as shown below. Click on the country drop down.
The only available option in this case is United States and under it select Alaska state. After selecting the above, then the number of buildings and file size is displayed in their corresponding text areas. Also ensure that the preferred save folder is selected. Click on Apply button to poceed.
A confirmation message similar to previous ones appears as shown below. Click Yes button to proceed.
Once the download is complete, a message box similar to others in previous steps is shown indicating that download has been completed. Click on OK button below.
After extraction another message box is shown and appears as below. Click OK button to proceed.
The downloaded data is visualized in the QGIS map canvas and appears as shown below. The data consist of buildings spanning across the state of Alaska.
Download Other Open Data
HCMGIS plugin supports dowloading of other data from the web through the Web Feature Service (WFS) which is an Open Geospatial Consortum (OGC) standard. Click on the the shortcut as shown below.
A window is displayed and contains controls based on the WFS specification such as the title and abstract which populate on selecting a supported service provider.
The supported service providers appear as shown below on clicking the Service Provider drop down.
One of the service providers is the HCMGIS OpenData and when selected, the abstract, title and WFS layers sections are populated and appear as shown below. This gives the user the chance to select an individual layer of interest for download.
Change the service provider to World Food Programme as shown below.
The WFS layers will change on changing the service provider. After selecting the provider, identify any layer on the WFS layers list. Note that the selected option is named geonode:food_insecurity at number 11.
Once that is selected, click Browser… button to point to the output folder where the data will be downloaded into.
Select SHAPE-ZIP as the output format which instructs the plugin to download data in the format of a zipped file.
The screenshot below shows the selected dataset of our interest.
Once Apply buton is clicked, the progress bar is activated and shows the download size in percentage. Once it completes, the progress bar appears as shown below, also the number of layers being downloaded is shown.
The data that has been downloaded appears in the QGIS map canvas as shown below.
The attribute table for the downloaded data appears as shown below.
In summary, the HCMGIS QGIS Desktop plugin can be leveraged in different ways based on users interest and can help achieve some user’s goals. Try the plugin for yourself and use different options and different datasets.
About HCMGIS Plugin
HCMGIS is a QGIS Desktop plugin that has been developed by Center for Applied GIS of Ho Chi Minh City and the code repository for the plugin can be accessed through this GitHub link and comprises of the following functionalities:
- Basemaps loader.
- Batch Converter for some GIS data formats.
- Downloader for Covid-19 Data.
- Downloader for datasets from various platforms.
- Downloader for Vietnam datasets.
- Geometry Processing tool.
- Calculate Field tool.
In this walkthrough we shall only look at the first four functionalities.
Installing HCMGIS Plugin
To install HCMGIS QGIS plugin, one can either download a zipped file from the HCMGIS Plugin repository or download directly from the QGIS Desktop Plugins menu. Below is a screenshot of the HCMGIS plugins repository for the HCMGIS plugin.
This walkthrough assumes that QGIS Desktop is already installed in the computer. If not, refer to the post on Installing QGIS Desktop in Windows 10 . This walkthrough has been done in Windows 10. After opening QGIS Desktop and installing the HCMGIS plugin, the plugin menu under installed section should appear as shown below.
The menu should also be visible in the QGIS menu as shown below.
When clicked the shortcuts under it appear as shown below. The items functions are as highlighted in the previous section.
Click on the BaseMap shortcut and the dropdown appears showing a list of all the basemaps supported by the plugin. Note that you require to be having an internet connection to load the basemaps as they are being loaded from the web.
Under BaseMap shortcut, click on the GoogleMaps option and a map is loaded in the QGIS Map Canvas and on the Layers Panel as a layer if active as shown below and is zoomed into Kenya’s bounds. The service is developed and maintained by Google.
When done with the above base map, close and click on the HCMGIS plugin once again and click on the Bing Virtual Earth option and the base map loads showing a terrain kind of map that looks like natural landscape with green vegetation. The free service can be used to view features on earth’s surface.
The next base map is the CartoLight base map which is maintained by Carto and can come in handy with custom data overlays or in designing a map in QGIS Desktop. There are other children of carto base maps that include Carto Dark and Carto Eco. Below is the Carto Light base map which is preferred for point data. The development repository can be accessed here.
The final base map in this walkthrough includes the WikiMedia base map which appears as shown below. There are a variety of basemaps that can be used under the HCMGIS plugin and just a few have been covered here.
After downloading the data, in the QGIS Desktop menu identify and click HCMGIS menu and if it is not visible revisit previous steps of opening the QGIS Plugin menu and activating or even re-installing the plugin otherwise, the clicking should show a dropdown that appears as shown below.
Click on the Vector Format Converter shortcut and this open a widget that appears as shown below and contains several controls; dropdowns, buttons and text fields.
Under the input format label is a drop down when clicked, shows all the supported input formats. In this case we will be working with ESRI shapefile denoted by SHP option therefore, select that option.
Similarly, under the output format label, select CSV as the option indicating that we shall be outputting our data in Comma Separated Value (CSV) file.
After selecting input and output formats, click on the Browse… button which will open an input folder window. Navigate to the folder containing the previously downloaded and extracted data and click OK button to close the window.
If pointed to the correct folder, the shapefiles existing in that folder will be shown as a list as shown below. The folder in this case contains four shapefiles.
After ensuring all above mentioned options are correct, click Apply button to proceed with the conversion.
After the conversion is complete, the progress bar will be at 100% and a label indicating number of files converted will be shown as below. If any errors occurred during conversion they will be displayed in the error log area below the progress bar.
The whole window appears as shown below after conversion.
Navigate to the output location that is similar to the input folder and additional files with a .csv extension will appear as shown below. They may be arranged by name or other field but the file type will be Comma Separated Values.
On loading the layers in QGIS Desktop and opening the attribute table, the data looks as shown below.
CSV to Point Converter
In this next step, we will select the CSV to Point shortcut as shown below.
This tool geocodes CSV data and converts them to shapefiles which is quite the opposite of what we did in the previous step only that in this step the input and output formats are fixed.
Click on Browse… button to browse to the directory containing input CSV files. The input files must contain coordinates fields in Latitude and Longitude otherwise the conversion will not take place. To mitigate this from happening, open the CSV data in a text editor or in QGIS Desktop to view the attribute data and confirm that it has coordinates.
The data used in this procedure can de downloaded from ArcGIS Hub data repository and is as listed below:
Once the data has been downloaded navigate in the browse window shown below to the folder containing the files and click Select Folder button to close.
Now that the input folder has been selected, the next step entails identifying the latitude and longitude fields. At times the plugin automatically detects the fields and lists them as shown in the screenshot below but at times the user may be forced to click on the drop downs below the Latitude Field and Longitude Field consecutively to identify the actual field name containing the coordinates.
Once selected every control as required, click Apply button to begin the conversion process. Once the process is complete the progress bar will be at 100% and the number of converted files will be shown in bold above the progress bar.
The previously existing files in CSV can be identified as shown below.
The newly created ESRI shapefiles can be identified as shown below.
To add the layers, click on the Add Vector Layer… shortcut as shown below.
The Data Source Manager window is displayed as shown below with the Vector option highlighted. Click on the button labelled … to browse the file system.
A file browser window similar to previous file browser windows is displayed as shown below. Point it to the files of interest and note that they end in .shp extension indicating that they are shapefiles and then click Open button.
The shapefiles are loaded as vector layers and displayed in the QGIS map canvas as shown below.
In the QGIS Desktop Browser panel, identiy XYZ Tiles and double click on it to collapse it and among the options identify OpenStreetMap that comes with QGIS by default.
This loads an Open Street Map base map however it appears on top of the vector layer therefore hiding the points and it is necessary to correct that.
In the layers panel shown below, drag the OpenStreetMap layer shown below by clicking and holding the mouse button downwards below the other two layers and it will appear as shown below.
And also for the map, the points will be seen to appear on top of the basemap.
In the above steps the conversion of datasets has been summarized and this shows that the HCMGIS plugin can come in handy and remove the repetitive process of converting multiple files by loading them into the QGIS Desktop and exporting them manually.
QGIS Desktop plugins extend the base functionalities of the GIS desktop software. On its own, QGIS Desktop can help users achieve a lot of tasks from digitizing, connecting to a database and creating of maps among others. Plugins enrich QGIS Desktop functionality and in this post we shall see our first example plugin that is the QuickMapService plugin. The tutorial highlights how to download, install and use the plugin.
QuickMapServices is a QGIS Desktop plugin that comprises of several web services, datasets and basemaps that can be used as a help to digitizing, comparing vector feature locations, change detection studies among many other tasks. It has been developed by NextGIS and its code repository can be accessed using this link. To install a plugin in QGIS Desktop, one can either download a zipped file from the QGIS Python Plugins repository or download directly from the QGIS Desktop Plugins menu. Below is a screenshot of the QGIS Plugins repository.
This tutorial assumes that QGIS Desktop is already installed in the computer. If not, refer to my post on Installing QGIS Desktop in Windows 10 and if using Ubuntu Linux refer to Installing QGIS Desktop in Ubuntu Linux this tutorial uses Ubuntu. Run the QGIS Desktop by clicking on the shortcut either pinned in the GNOME taskbar as shown below.
Alternatively, the QGIS Desktop shortcut can be accessed by clicking the home key in the keyboard (could be marked as a windows key) and type in the search area QGIS and the shortcut shall appear as shown below as long as one has QGIS installed in the computer.
After clicking the QGIS Desktop shortcut, then the splash screen is displayed for few seconds and appears as shown below. Note that the splash screen differs with the QGIS Desktop version installed in the computer.
After the splash screen disappears, the QGIS Desktop user interface is displayed and contains different controls and menus. The screenshot below shows the user interface in its default state and may differ with others if user interface settings have been customized. To understand the QGIS Desktop user interface, view my post on Exploring the QGIS Desktop User Interface .
In the Menu Bar at the top just below the black title bar lies all the menus that are shown in the QGIS by default. Some plugins once installed populate or insert additional menus. Identify the Plugins menu that is between Settings and Vector menus above and click on it and the drop down containing a list of two menus pops down as shown below.
Click the Manage and Install Plugins… shortcut which triggers a connection to the QGIS Plugins Repository shown at the beginning of this post but from the QGIS user interface.
If the connection is successful then the plugins widget appears as shown below containing all the install-able plugins from the plugin repository. Otherwise a message box showing error in connection is displayed and the plugins menu shown will only have the QGIS core plugins under the Installed tab menu.
Click in the search bar at the top and type QuickMapService and the plugins will be filtered as typing continues and will finally show the plugin of our interest as shown below.
Click on the Install Plugin button at the bottom right of the widget. If already installed then the buttons will be labelled Uninstall Plugin and another one labelled Re-install Plugin. Ensure that connection to the internet is working as it downloads the plugin files from the internet.
Once installed, ensure that the left checkbox is checked as shown below for the QuickMapServices plugin meaning that it will be active in the QGIS Desktop user interface.
Close the plugin widget and in the QGIS Desktop user interface, there will be a docked widget which for now can be closed since it is not being used in this task.
Identify and click the Web menu in the menu bar area and a dropdown appears as shown below. Hover the cursor on top of the QuickMapServices.
The drop down shows only five services however these could be very few for most usages and tasks. Therefore there would be need to add more services.
Luckily, instead of using an additional plugin or looking for web map services’ urls on the web which could be time consuming, QuickMapServices plugin has settings to add these extra services if they appear as shown above. On the plugin menus just below the services shown above, identify and click settings which is highlighted below.
The settings comprise of a number of tabs in which the More Services tab is of our interest therefore click on it if not active and the contents will appear as shown below. Click on the button labelled Get contributed pack below.
The additional services are installed from the internet and this process will only be successful if there is working internet connection otherwise an error in connection message will be shown.
Click OK above and in the settings widget click on save button shown as below.
To show the added services, click on the QuickMapServices menu under Web QGIS menu and they will appear as shown below.
We shall begin by loading a Google Satellite base map by selecting the options as shown below.
By clicking on the Google Satellite option, the layer from Google Satellite is loaded on the QGIS map canvas area and on the layers panel all as shown below.
One can also zoom into the image and an example of the layer display after zooming in appears as shown below. The area shown is a part of Lake Victoria located in western part of Kenya in East Africa region.The second service to load will be ESRI Satellite basemap that appears under the ESRI option as shown below.
On selecting the ESRI Satellite option, the basemap is loaded as a layer in the QGIS map canvas just like in the previous step. It may seem somewhat similar but also with some differences to the previous but the provider (ESRI in this case) is different.
The final service that we will load in this tutorial will be Stamen Terrain whose options appear as shown below.
On selecting Stamen Terrain, the layer is visualized in the QGIS map canvas layer and is as shown below. As it can be noticed, the style of the layer below is different from the previous layers.
We have been able to install QGIS plugin named QuickMapServices and can come in handy for tasks such as having a base map layer for map, digitizing of features from layer and Geo-referencing tasks just to mention a few. This plugin is also flexible on the number of services that on e can work with therefore give it a try.
Python is one of the most commonly used high-level programming language that was invented by Guido Van Rossum in 1991 and is maintained by the Python Software Foundation. One of the major contributors to Python’s rise to fame is its development which had emphasis on code readability and expression of concepts by programmers in fewer lines of code.
Python is a cross-platform software and its learning curve is somewhat smooth learning curve as compared to some other programming languages.
This tutorial highlights the steps taken in installing Python software in Windows 10 operating system and can act as a guide to those beginners who would like to try out the language and also those who might experience challenge in installing the software.
To download Python, navigate in your preferred browser to the download page in Python’s official website. When the web page opens it appears as shown below and contains a list of all the Python’s releases for Windows. Click on the first link labelled Download Windows Installer (64-bit) which assumes that you are using a 64-bit computer otherwise you can download the 32-bit one. The latest version as of this tutorial is version 3.9.2.
The download session starts once the link above has been clicked. The browser being used below is Microsoft Edge therefore if one is using another browser the download window could look different from this one.
Once the download is complete, in open the file explorer and navigate to Downloads folder and the downloaded installer appears as shown below. Note the amd64 suffix that indicated that this is a 64-bit installer.
At this point we have been able to successfully download python installer in the Windows machine and the next step will be to install Python.
To install Python, double click the downloaded installer or alternatively right click and select the first option labelled open and the installation wizard will appear on the screen as shown below. Click on the Customize installation option.
This page shows several options among them being to install with the default settings and to customize the installation. The important thing in the window above is to ensure that the second checkbox is checked as shown thus ensuring that Python is added to the windows path.
On clicking the customize option, the installation window displays all the optional features and gives the user the liberty to check and uncheck the options shown. Leave the checkboxes as they are and click Next button.
The window showed below contains the list of advanced options for installation and the text besides the checkboxes explains what each option does and below it the path to the directory of installation. Once satisfied with the options, click Install button.
On clicking Install button above, the installation process begins and the progress of the installation is indicated by the green progress bar shown below.
The installation process may take some minutes depending on the computer processing power and memory. When the installation has completed successfully, the following message is shown in the installation wizard. To view the online tutorials, documentation and the new Python features click on each of the links consecutively, otherwise click Close button to close the installation wizard.
After closing the installation wizard, click on the start button on your keyboard that in most cases is a key that has a Windows logo icon on it and type Python and by default, Windows filters the items with the name and the item of our interest in this is the option that has the python console icon as shown below.
Click on the icon shown above and a black window that looks similar to the Windows Command Prompt (CMD) appears as shown below. This window is referred to as the Python Console and the consist of three symbols >>> and a blinking cursor.
The Python Console can also be referred to as the Python Interactive Shell or the REPL standing for Read Evaluate Print Loop. It is an interactive window that one can type in commands and it shows an output. An example of the interactivity is demonstrated in the shell below. Once your Python shell is open, then type the following line of code.
And it shall print out Hello world text as shown below.
We have been able to install and run Python in this tutorial. For more detailed documentation on Python visit the Python Documentation.