Distance Matrix Analysis and Spatial, Non-Spatial and Temporal Querying with QGIS

From CUOSGwiki
Jump to navigationJump to search

Purpose

The objectives of this tutorial are to demonstrate how to convert CSV files to shapefiles, how to complete a Natural Neighbour Analysis using the Distance matrix tool, and how to query using Quantum GIS 2.0.1. This is done by comparing open source data. This tutorial compares Significant Earthquakes from 1990 - 2013 in North America and their relation to Populated Places around the globe. The earthquake data was retrieved from the Significant Earthquake Database on the National Oceanic and Atmospheric Administration Website [1], and the Populated Places data was retrieved from the Natural Earth Website [2].


The Purpose of this tutorial is to fulfill the partial requirements of the GEOM 4008 - Advanced Topics in Geographic Information Systems class' final exam project at Carleton University. The purpose of this project was to explore the advantages and disadvantages of different open source geographic information systems (GIS) programs.

Introduction to Quantum GIS 2.0.1

Quantum GIS 2.0.1 is a free Open Source Geographic Information System (GIS) program that is used to create, edit, visualize, analyze and publish geospatial information (CITE). The program is available for Windows, Mac, Linux, and BSD. This user friendly Open Source GIS program is licensed under the GNU General Public License and is an official project of the Open Source Geospatial Foundation. [3]


QGIS has many different features including QGIS Desktop, where you can create, edit, visualize, analyze and publish geospatial information; QGIS Browser, where you can browse and preview your data and metadata as well as more around your stored data; QGIS Server, where you can publish your QGIS projects as OGC compatible WMS and WFS services; and QGIS Web Client, where you can publish your QGIS projects.[4]


Qgis-logo.png


Downloading QGIS

Before you begin the tutorial, if you do not have the 2.0.1 version of QGIS please follow the steps below:

  • Follow this link to download [5]
  • Choose which version is compatible with the computer you are working on
  • Follow the steps in the popup downloading window


Acquiring the Data

To download the Earthquake data follow these steps:

  • Visit the Significant Earthquake Database at this link [6]
  • Fill in the date of the form beginning in 1990 and ending in 2013
  • Select North America and Hawaii as the Region Name
alt text







  • Select Search Database at the bottom of the page
  • copy all features and paste into a text file
  • Save to folder


To download the Populated Places data follow these steps:

  • Visit the Natural Earth Website at this link [7]
  • Click to download the 1.47MB version of the Populated Places.
  • Download the file
  • Unzip the file
  • Save to same folder as the the Earthquake file

Tutorial

Adding CSV File

  • Once QGIS 2.0.1 opens, start by clicking the Add Delimited Text Layer
Step2.png








  • Fill in the Create a Layer from a Delimited Text File window with the proper information and attach the text file.

DISCLAIMER: if an error occurs, it is because one our your features does not contain proper coordinates

Textdelim.png









  • Now choose your reference system, for the purpose of this tutorial, WGS 84 was chosen
Textdelim2.png











  • Your CSV layer is now added to QGIS



Distance Matrix Analysis

  • First we need to add in the Populated Places data
  • Navigate to the side bar or to the vector drop down menu on the above task bar and click Add Vector Layer
Addvector.png








  • Using the Add Vector Layer popup, navigate to your Populated Places Data and click Open

Addvector2.png






  • Your screen should now look something like this:
Data.png







  • Now to begin the Natural Neighbour Analysis by creating a Distance Matrix
  • Using the Vector drop down menu on the tool bar, select Distance Matrix under Analysis Tools

Distmatr.png






  • To fill in the Distance Matrix Window, select Earthquakes as you Input point layer, Name/Location as your Input Unique ID field, Populated Placeslayer as your Target Point layer, and the Name of the Populated Place as the Target Unique ID field.
  • Now for the Output Matrix Type we are going to pick a Linear (N*k x 3) distance matrix and also check off the box for only using one of the nearest (k) target points. This is because we are look for the Natural Neighbour to each earthquake and we only want to know the single closest city.
  • The window should look something like this:


Distmatr2.png




  • Using the browse button, navigate to the folder where the Earthquake and Populated Places files are saved and create a name for the output Matrix.
  • Now to complete the matrix hit OK.
  • Now to manually add the output matrix into QGIS, use the same method as adding the Populated Places data by using the Add Vector Layer button.
  • To view the results of the Distance Matrix, RIGHT Click on the matrix in your Layers window on the left side of QGIS Desktop. Then click on Open Attribute Table like displayed in the image below:

Openatt.png


  • The attribute table of the Distance Matrix should look something like the image below, where the first column is the Name/Location of the earthquakes that was chosen for the Unique ID, the second column shows the target unique ID representing the closest populated city by Name to the earthquake, and the third column represents the distance in degrees to the nearest earthquake.

Matrixtable.png


  • To make for a simpler comparison, we are going to join the distance Matrix attribute table to the earthquake attribute table. To do this right click the earthquakes layer, and select properties like in the image below:

Properties2.png


  • Once the Layer Properties window is open, open the Join tab on the left side of the window and click the add button at the bottom like in the image below:

Addjoin.png