Difference between revisions of "IDW interpolation using QGIS"

From CUOSGwiki
Jump to navigationJump to search
(Minor edits of typographical and style issues)
 
(9 intermediate revisions by one other user not shown)
Line 1: Line 1:
  +
== Introduction and Purpose ==
== What to expect from this Tutorial ==
 
  +
Using spatial data, it is possible to analyze, interpret, and represent phenomena almost everywhere on Earth. But what can be done when data exists near our area of interest, but not directly at the location? In these situations, we can use Inverse Distance Weighting (IDW) interpolation, a process that calculates values for locations based on nearby known values. It operates on the first law of geography, which states that near things are more alike than far things and assigns greater influence to known values that are nearby than those that are distant. In this tutorial, we will be conducting IDW interpolation in QGIS, an open-source GIS system. Open-source ([https://en.wikipedia.org/wiki/Open_source]) is a term that refers to having accessible, free, and redistributable programs available to the public. This allows for individuals to work on the code together to create a model that encourages open collaboration and develops code together. To look at GIS programs available for free download, you can visit the [https://www.osgeo.org/choose-a-project/] page to look at all the projects currently being worked on by the community.
   
  +
The purpose of this tutorial is to expand your abilities in QGIS by teaching you how to run an important analysis tool- IDW interpolation [[http://en.wikipedia.org/wiki/Interpolation]], with the end goal of creating an interpolated raster surface. The difficulty level for this tutorial is an entry-level QGIS user. This tutorial will contain screen-shots for each step to show the path to create all the layers that are in the finished product.
Going through this tutorial using '''' Quantum' GIS''' ([https://en.wikipedia.org/wiki/QGIS]):
 
You will be gain the following skills.
 
* Importing CSV file
 
* creating interpolated raster surfaces using IDW
 
* symbolizing the interpolated raster surfaces
 
* clipping raster surfaces with base map polygons
 
* exporting the raster surfaces as a finished map.
 
 
== Purpose ==
 
 
[[File:QGIS logo.png|thumb]]
 
[[File:QGIS logo.png|thumb]]
  +
<br clear=all>
The purpose of this tutorial is to expand your ability to run important analysis tools such as Interpolation and Image analysis (IDW) [[http://en.wikipedia.org/wiki/Interpolation]], using several proprietary tools [http://en.wikipedia.org/wiki/QGIS], with the end goal of creating a finished IDW interpolation map. The difficulty level for this tutorial is an entry-level QGIS user, But it is assumed that the user has some experience with other GIS systems Such as ArcPro or ArcMap. I chose to create this tutorial to try and bridge the gap between this software and Esri’s products. Making it easier to learn how to use the software and carry out the functions that the user is already familiar with.
 
* This tutorial will be incorporating some screen-shots for each step to show the path I took to create all the layers that are in the finished product
 
   
  +
=Tutorial=
   
  +
== Downloading QGIS ==
   
  +
This tutorial uses QGIS, you will need to have the software installed [[https://qgis.org/en/site/forusers/download.html]] on your desktop or laptop. This tutorial uses QGIS 3.23.
 
 
 
------------------------------------------------------------------------------------------------------------------------------------
 
 
== Introduction ==
 
 
The purpose of this tutorial is to learn how to use the proprietary tools in an open-source platform. I decided to do this in QGIS as the software is often looked at as the main competitor to Esri as the design and application are similar to that of ArcPro and ArcMap. This tutorial looks to try and bridge the gap between this software and Esri’s products, to make it easier to learn how to use the software and carry out the functions that the user is already familiar with. Although the software looks similar differences between QGIS and Esri’s products which are often taken as the industry standard. This all ties into making this tutorial practical and accessible for all users picking up this software for the first time, or just wanting to expand their knowledge. This was chosen to help show off the strength of open-source software in a practical way encouraging those to use it more often.
 
 
=Open-Source=
 
open-source ([https://en.wikipedia.org/wiki/Open_source]) is a term that refers to having accessible, free and redistributable programs available to the public. This allows for individuals to work on the code together to create a model that encourages open collaboration and develops code together.
 
 
=GIS=
 
In our case, a license subscription to Esri can be extremely expensive to have just one account leading to a lot of overhead costs for full teams. This is why having open-source and freely available software is vital for users to know to bring down costs where possible.
 
To look at GIS programs available for free download, you can visit the [https://www.osgeo.org/choose-a-project/] page to look at all the projects currently being worked on by the community.
 
 
== Downloading QGIS (3.22)==
 
 
For this tutorial, you will need to have QGIS installed [[https://qgis.org/en/site/forusers/download.html]] on your desktop or laptop. At the time of creating this tutorial, QGIS 3.22 is the most recent version and the version all of this tutorial is being done in.
 
 
Once you have selected the version you wish to download based on your operating system, follow the guide that is installed in the package.
 
Once you have selected the version you wish to download based on your operating system, follow the guide that is installed in the package.
With QGIS 3.22 now installed on your computer and a proper path for accessing the application on your hard drive, you are now able to start the tutorial!
+
With QGIS now installed on your computer and a proper path for accessing the application on your hard drive, you are now able to start the tutorial!
 
 
This tutorial was created as a result of the final project given out in the GEOM-4008 GIS course at Carleton University. If you wish to look at other tutorials created by other students, they can be found at [[https://dges.carleton.ca/CUOSGwiki/index.php/Main_Page]]
 
 
= Data =
 
 
The data I selected for this tutorial go along with the theme of keeping everything open source and using publicly available data from the Canadian government. To ensure the longevity of this data we will be using monthly climate summaries from Stat CAN as it is very extensive and easily accessible data for all provinces and territories in Canada. This in-depth look at provincial weather will be the best and easily malleable data set to use for our project. For this case, we will be looking at Alberta's average mean temperature. This will give us a good well-distributed data set that we will be able to use to create an IDW model and help us guess the values of areas that we do not know.
 
 
==Downloading the data==
 
# Go to [[https://climate.weather.gc.ca/prods_servs/cdn_climate_summary_e.html]] and scroll to the bottom of the page
 
# Begin by clicking the year 2 years before your current date (e.g. as of today it's Decemeber 2021 so I would use December 2019 etc);
 
# Select your area of interest (for this assessment I used Alberta as it has the most climate stations in the country)
 
# ensure that you are downloading the CVS data and click the download button when ready.
 
# Be sure to also download the Legend(txt) file as it will allow you to see what all the data is meant to represent
 
# We now need our boundary file, to get this go to [[https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2011-eng.cfm]] and download the ArcShape file and click the provinces under "Cartographic Boundary File"
 
# this will bring you to a second screen that says "Archived – gpr_000b11a_e.zip (ZIP version, 40,968.0 kb)" click this and download this for the project
 
 
 
[[File:Screen Shot 2021-12-23 at 10.47.38 AM.png|thumb|left]]
 
[[File:Screen Shot 2021-12-23 at 10.52.41 AM.png|thumb]]
 
 
 
 
 
 
 
 
 
 
 
 
 
   
   
  +
== Data ==
   
  +
The data used in this tutorial is monthly climate summaries from Statistics Canada, which publishes extensive and easily accessible data for all provinces and territories in Canada. For more information about the data, visit the "About the Data" page here [[https://climate.weather.gc.ca/]]. This in-depth look at provincial weather will be an easily malleable data set to use for the tutorial. In this example, we will be looking at Alberta's average mean temperature. This will give us a well-distributed data set that we will be able to use to create an IDW model and help us calculate the approximate temperature values of areas that do not have weather stations.
   
  +
===Downloading the data===
  +
# First, set up a folder in your file directory for your project. This will be where you save all your data and your QGIS project
  +
# Next, go to [[https://climate.weather.gc.ca/prods_servs/cdn_climate_summary_e.html]] and set the date to December of 2019
  +
# Select your area of interest (for this assessment, Alberta was used as it has the most climate stations in the country)
  +
# Select CSV as the data format and click "Download data" to start your download
  +
# You can also download the Legend(txt) file as it will allow you to see what all the data is meant to represent
  +
# Next, we will download our provincial boundary file from [[https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2011-eng.cfm]]
  +
# Select your preferred language, the .shp file format, and provinces/territories under "Cartographic Boundary File"
  +
# Next hit continue at the bottom of the page, this will redirect you to a new page with a link labelled "Archived – gpr_000b11a_e.zip (ZIP version, 40,968.0 kb)" click the link to download the .zip folder
   
  +
[[File:Screen Shot 2021-12-23 at 10.47.38 AM.png|500px|thumb|left]]
  +
[[File:Screen Shot 2021-12-23 at 10.52.41 AM.png|600px|thumb]]
   
   
   
  +
<br clear=all>
 
===Editing the data===
 
===Editing the data===
With this data having so many variables we need to edit it to make it easier to work with:
+
With this data having so many variables, we need to edit it to make it easier to work with:
# Open your CVS file using Excel (or other spreadsheet software) and make sure that you select "separated by a comma" to format the file correctly.
+
# Open your CSV file using a spreadsheet software like Excel
  +
# Right-click on the "Clim_ID" column to select the entire row
# beginning with the variable to include in the set, use your legend(txt) file to locate the mean temperature and delete all other variables not dealing with location or identification
 
# Right click on the "Clim_ID" column to select the entire row
+
# Use the sort/filter drop-down menu and filter the "Clim_ID" column from largest to smallest
  +
# Select the rows with values that contain letters and delete them from your file. These rows are not needed and can create some issues when loading the data into QGIS
# under the home tab of Excel click the sort/filter drop-down menu and select largest to smallest.
 
  +
# Save your worksheet as a CSV in your project folder and close your spreadsheet software
# You should see a bunch of stations that are all formatted to the left of the cell and will contain letters unlike the rest of the data set. Select all these rows and delete them from your file (do not worry, they are not needed and can create some issues when loading the data into QGIS)
 
# Once you have done this save your data and you are ready to bring them into QGIS
 
##note: If you are having issues with bringing the data into QGIS make sure that all of your climate ID's are correctly formatted as this can stop the data from being able to be read by QGIS
 
[[File:Screen Shot 2021-12-23 at 11.07.44 AM.png|thumb]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
----------------------------------------------------------------------------------------------------------------------------------
 
 
=Tutorial=
 
 
==Loading CSV File and Provincial Boundary File==
 
 
 
[[File:Screen Shot 2021-12-22 at 10.49.12 PM.png|thumb]]
 
 
* Launch QGIS (version 3.22 or newer) and ensure that you have downloaded the correct data sets. and create a new project file
 
 
# at the top of your toolbar, click the plugin tab and click the "manage and install plugins" item.
 
# In the "all" tab, search for the "QuickMapServices" plugin and install it to QGIS. once this is done restart QGIS
 
# once you are back into a new project layer, click the web tab at the top and go to the QuickMapServices dropdown and select oms standard. (this should add in a base map to your project)
 
# we will now add in our 2 layers starting with the weather stations. by clicking on the layer tab at the top of the page go to the "add layer" tab and scroll to the "Delimited Text layer"
 
# in the new window, click the 3 dots at the top right corner of the screen (you will be finding the CVS file that we edited earlier) once you have found it make sure that the "Comma" and "tab" boxes are checked off in the "custom delimiters" file format
 
# in the Geometry definition option set your x field to "Long" and your y field to "Lat" so that QGIS knows how to read your coordinates
 
# click on the layer tab at the top of the page go to the "add layer" tab and scroll to the "add Vector layer" tab
 
# in the new window, click the 3 dots at the top right corner of the screen (you will be finding the boundary file we downloaded) in the package you downloaded click the file with the .shp end to it and add it to your project
 
## once it is loaded in right-click on it and select "Open attribute table"
 
## once open click the pencil at the top of the window. then select all layers besides Alberta and click the " delete selected feature" tap on the toolbar you clicked the pencil on
 
## once this is complete correctly you should only have the Alberta boundary file on your project layer (and the weather stations)
 
[[File:Screen Shot 2021-12-22 at 10.32.11 PM.png|thumb]]
 
# The next step will be to create a permeate layer for your weather station points. to do this right-click on the layer and click export "save feature as"
 
#Give this a name and click the 3 dots next to your name for the layer. create a space where you will be saving all your file layers ( I would recommend creating a new folder to keep everything in to keep all your paths the same for the project) once all of this is done it should look something like this
 
[[File:Screen Shot 2021-12-22 at 11.23.32 PM.png|thumb]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
----------------------------------------------------------------------------------------------------------------------------------
 
 
==Interpolating data to create a Raster Surface layer==
 
[[File:Screen Shot 2021-12-23 at 12.16.29 AM.png|thumb]]
 
#Begin by clicking the processing tab at the top of the application window and selecting the
 
"toolbox" tab. This should bring up a menu on the left side of the application with a search bar at the top of its menu.
 
#in the search bar type in "IDW Interpolation". there will be several options that come up but for our tutorial, we will be using the proprietary tool that QGIS officially backs and created for its software. Once you have located it double click the tool to open the IDW window
 
#In the new window, where it says "Vector layer" select the name of the weather station layer we created earlier. Once this is done it will ask for the interpolation attribute that you will be interpolating, select the "Tm" attribute as this is what we will be working with
 
#right bellow interpolation attribute drop down there is a plus button, click this and the layer will be added the table below. In this table select the "points" tab under the type dropdown.
 
# below this we have the Distance coefficient P set at a default of 2, I would recommend increasing this to 5 to account for the northern and western portion of Alberta since these areas have very little station data available compared to southern Alberta. this will add more weight to pixel values and their distance to other stations.
 
#below this there is the extent tab with a dropdown on the right side of the terminal, click this and go to calculate from layer, this will bring up the other layers currently on your map. Select your boundary file as the extent
 
# if everything is done correctly it should look like the picture shown below. if it does click the "Run" button at the bottom of the window.
 
 
 
 
----------------------------------------------------------------------------------------------------------------------------------
 
 
==Clipping Interpolation Surface to create a final raster layer==
 
 
* This portion of the tutorial will focus on creating a masked layer for the raster layer we just created to fit within our boundary file.
 
* at the top of the application there is a raster tab, click this and scroll to the "extraction" tab and select the "clip raster by mask layer"
 
[[File:Screen Shot 2021-12-23 at 12.25.12 AM.png|thumb]]
 
*At the top of the window select your interpolated layer as the "input layer". you want to mask it to the shape of Alberta so choose the boundary file as your "mask layer"
 
*Ensure that both layers are using the same projection and then click run.
 
[[File:Screen Shot 2021-12-23 at 12.39.28 AM.png|thumb]]
 
 
 
 
 
 
 
 
* You will notice that these layers are only temporary and if you were to close the application right now the layer would not save to combat this we need to export the layer as its GeoTIFF file so that we can share your data later.
 
#to do this right-click on the layer and click export "save feature as"
 
#Make sure the format is GeoTIFF and click the 3 dots next to the file name. in the folder you created earlier give this layer a name like AB Weather IDW. once all of this is done it should look something like the figure on the left
 
[[File:Screen Shot 2021-12-23 at 12.48.13 AM.png|thumb]]
 
 
 
 
 
 
 
* to finish this layer off we will be changing the symbology as the tones of gray are hard to grasp with a dataset like this. to change this right-click on the new layer and select the "properties" button at the bottom of the pop-up window.
 
* at the top of this window it says "render type" click that menu and select "single-band pseudocolour". this will allow you to select a colour ramp different from black and white select something that makes sense for your map, of this example I have used the "plasma" ramp to show the difference between the warmest temperatures and the coldest.
 
 
 
 
 
 
 
 
 
 
 
[[File:Screen Shot 2021-12-23 at 1.08.23 AM.png|thumb]]
 
 
 
 
 
 
 
 
* Once this has been completed and looks complete save your project by clicking the project tab and selecting "save as" this will bring you to the folder you created earlier. Name your project Alberta Weather IDW map and click "save".
 
* once this is completed the analysis portion of the tutorial is over and you successfully ran an interpolation on open source software!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
----------------------------------------------------------------------------------------------------------------------------------
 
 
==Exporting the Final Maps==
 
 
* Under the ‘Project’ tab, select “New Print Layout".
 
* Name this print layout something like IDW MAP FINAL then click ok, this should bring you to an entirely different window like the one on the right.
 
 
 
 
 
 
   
  +
[[File:Screen Shot 2021-12-23 at 11.07.44 AM.png|center|700px|thumb]]
   
   
[[File:Screen Shot 2021-12-23 at 1.23.03 AM.png|thumb]]
 
   
   
  +
==QGIS==
   
   
  +
===Loading CSV File and Provincial Boundary File===
   
   
  +
* Launch QGIS and create a new project file. Save your project to the folder you created at the start of the tutorial
   
  +
* At the top of your toolbar, click the plugin tab and click the "manage and install plugins" item.
  +
* Search for the "QuickMapServices" plugin in the pop-up window and install it to QGIS. Save your project, close and re-open the QGIS application to activate the plug-in
   
  +
[[File:Plugin 1.png|500px|thumb|left]]
  +
[[File:Plugin 2.png|700px|thumb|center]]
   
  +
* After reopening your project, click the Web tab on the menu, then QuickMapServices dropdown and select OSM standard. This will serve as a base map to your project
   
  +
[[File:Plugin 3.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
* Add in the monthly climate summary data by clicking on the layer tab in the menu, selecting "Add Layer" and clicking "Add Delimited Text layer"
   
[[File:Screen Shot 2021-12-23 at 1.28.46 AM.png|thumb]]
+
[[File:CSVI 1.png|700px|thumb|center]]
  +
<br clear=all>
   
  +
* In the pop up window, click the 3 dots at the top right corner of the screen (highlighted in blue in the image below) and navigate to your project folder. Select the climate summary CSV file. In the Geometry definition option, set your x field to "Long" and your y field to "Lat" (highlighted in yellow) to set your coordinates
   
  +
[[File:CSVI 2.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
* Click on the layer tab in the menu, go to the "Add Layer" tab and select "Add Vector Layer"
   
  +
[[File:VI 1.png|600px|thumb|center]]
* on the left side of the screen you will see an icon that looks like a rolled-up map and if you hover over the button it says 'add Map' click this to bring in the map we just created. You can now fit the map to the size of the print layout and adjust the placement and size of the map on the left with the move "item content" and "select/move item" tools.
 
  +
<br clear=all>
* once you are satisfied with the placement you can start adding in other map elements to display the data in the easiest way possible, we will start by adding in a legend to make sense of our IDW
 
*By clicking the legend icon labelled "add legend" you can now click and size your legend to fit in your map. Since we are in the layout view and not the mapping tool itself you may see some items in our legend that we do not want there. to remove these unwanted items be sure to unclick the "auto-update" box under the "legend items" tab on your right.
 
   
  +
* In the pop-up window, click the 3 dots at the top right corner of the screen (highlighted in blue in the image below) and navigate to your project folder. Select the boundary file with a .shp ending
   
  +
[[File:VI 2.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
* Right-click on the boundary layer and select "Open attribute table"
  +
* In the pop-up window, click the pencil (circled in yellow) at the top right of the window to begin editing. Select all layers except Alberta and click the "Delete Selected Feature" tool (circled in red) on the menu
   
  +
[[File:AT 1.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
* Right-click on the boundary and toggle editing to stop editing the layer. Select the "Save your Edits" option from the ensuing pop-up
  +
* The following step is to save both of your layers as individual files. If this is not done, they will have to be re-created each time you open your project. To do this, right-click on the layer, click "Export", then select "Save Feature As"
   
  +
[[File:SVS 1.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
* In the pop-up window, click the 3 dots (highlighted in blue) and navigate to your project folder. Give your feature an appropriate name, and then click "Okay"
  +
* Repeat this step for both the boundary and weather station layers
   
  +
[[File:SVS 2.png|600px|thumb|center]]
  +
<br clear=all>
   
   
   
[[File:Screen Shot 2021-12-23 at 1.50.54 AM.png|thumb]]
 
   
   
  +
===Interpolating data to create a Raster Surface layer===
   
  +
* Click the processing tab or the gear icon in the menu
   
  +
[[File:MENU 1.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
* This will bring up a menu on the left side of the application with a search bar at the top of its menu. Click on the "Interpolation" row to open the sub-menu. Once you have located it, double-click "IDW Interpolation" (highlighted in yellow) to open the tool window
   
  +
[[File:TB 1.png|600px|thumb|center]]
* Once it is unclicked you can select a feater that you do not need in your legend and remove it with the minus button on the bottom of the "Legend item" menu. make sure to title your legend something appropriate for your reader to understand what the symbols are representing in your data.
 
  +
<br clear=all>
*from this menu you can adjust the font, size and background for the legend to get your desired aesthetic (get creative while keeping the elements of what make a good map in mind).
 
* Below the "add legend" button, add in a scale bar and northern arrow of your choosing adjusting the design elements to match the rest of the map. For the Scale bar, you can adjust how many segments are being displayed and how the increments go up.
 
* to cap off the layout include a title that explains a little about the map itself for example "Alberta weather interpolation for December 2019"
 
   
  +
* In the new window, select the weather stations layer from the "Vector layer" drop-down. Next, select "Tm" from the "Interpolation attribute" drop-down to assign the mean temperature as the value we are interpolating
* when you are happy with what you have click the layout tab at the top of the application and select "export as image" or "export as SVG" to export it as a jpeg or SVG. Both are acceptable it just depends on what you will be needing it for after you have finished.
 
  +
* Click the plus button (highlighted in yellow) to add the stations layer to the "Vector layer" list. Select the "points" tab under the "Type" drop-down
   
  +
[[File:IDW 1.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
* Click the drop-down by the "Extent" option to limit the extent of the interpolation. Click "Calculate from Layer" and select your boundary file as the extent
   
  +
[[File:IDW 2.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
* Once the processing is complete, the result should resemble the image below
   
  +
[[File:IDW 3.png|600px|thumb|center]]
  +
<br clear=all>
   
   
[[File:IDW map layout.jpg|border|center|800px]]
 
   
  +
===Clipping Interpolation Surface to create a final raster layer===
  +
  +
* Click the "Raster" tab in the menu and select "Extraction", then "Clip Raster by Mask Layer"
   
  +
[[File:Clip 1.png|600px|thumb|center]]
  +
<br clear=all>
  +
  +
* In the window, select your interpolated layer as the "Input Layer". Next, select the boundary layer as the "Mask Layer"
   
  +
[[File:Clip 2.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
* Right-click on the new layer and select the "Properties" button at the bottom of the pop-up menu
  +
* In the new window, change the "Render type" to "Singleband pseudocolor" using the drop-down menu (highlighted in yellow). Next, select the red to blue colour ramp using the "Color ramp" drop-down and selecting "All Color Ramps". Invert the colour ramp so that red represents higher temperatures and blue colder using the "Invert Color Ramp" function in the "Color ramp" drop-down (highlighted in blue)
   
  +
[[File:Col 1.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
* Next, export the layer by right-clicking and selecting "Export" and "Save Feature As".
  +
* Set the "Format" to GeoTIFF and click the three dots to navigate to your project folder. Name your file, then click "OK" to save
   
  +
[[File:Clip 3.png|600px|thumb|center]]
  +
<br clear=all>
   
  +
*Your project should look like the image below
   
  +
[[File:Col 2.png|700px|thumb|center]]
  +
<br clear=all>
   
*Once you have saved this you have fully completed this tutorial!
 
   
  +
* Once this is completed, the tutorial is over and you successfully ran an interpolation on open-source software! Thank you for following along, and we hope that this has been helpful - Pierce and Alex
=Conclusion=
 
   
In conclusion, this tutorial aimed to try and bridge the gap between this software and Esri’s products, to make it easier to learn how to use the software and carry out the functions that the user is already familiar with. This all ties into making this tutorial practical and accessible for all users picking up this software for the first time, or just wanting to expand their knowledge. I had originally intended to make this tutorial a kriging tutorial as the data we were using would greatly benefit from weighting distance and degree of variation when predicting the data in an area of interest. unfortunately, all the plugins I tried to use did not work when I tried to run any data through them to create a kriged layer. This led me to make the switch to an IDW map even though it would not allow me to work with the semivariogram to adjust the model. I tried using open Smart map and SAGA plugins with no success even after trying to troubleshoot with the professors themselves. In the future, I would love to see if someone could change this into a kriging tutorial as it would greatly benefit this data and push the tutorial even further. Had I been given more time I would have also expanded the tutorial to use PostGIS, GeoNode or MapServer to expand the tutorial’s viability even more. This would have allowed for easy sharing and the ability to update the data in real-time. None less I hope you learned something about open source programs with this tutorial and that you can update any areas I missed in the future. Feel free to email me if you have any questions or need any advice about the tutorial
 
   
best, Pierce
 
   
   
   
.
 
pierce.w.burch@gmail.com
 
   
 
=Resources=
 
=Resources=

Latest revision as of 10:57, 30 October 2023

Introduction and Purpose

Using spatial data, it is possible to analyze, interpret, and represent phenomena almost everywhere on Earth. But what can be done when data exists near our area of interest, but not directly at the location? In these situations, we can use Inverse Distance Weighting (IDW) interpolation, a process that calculates values for locations based on nearby known values. It operates on the first law of geography, which states that near things are more alike than far things and assigns greater influence to known values that are nearby than those that are distant. In this tutorial, we will be conducting IDW interpolation in QGIS, an open-source GIS system. Open-source ([1]) is a term that refers to having accessible, free, and redistributable programs available to the public. This allows for individuals to work on the code together to create a model that encourages open collaboration and develops code together. To look at GIS programs available for free download, you can visit the [2] page to look at all the projects currently being worked on by the community.

The purpose of this tutorial is to expand your abilities in QGIS by teaching you how to run an important analysis tool- IDW interpolation [[3]], with the end goal of creating an interpolated raster surface. The difficulty level for this tutorial is an entry-level QGIS user. This tutorial will contain screen-shots for each step to show the path to create all the layers that are in the finished product.

QGIS logo.png


Tutorial

Downloading QGIS

This tutorial uses QGIS, you will need to have the software installed [[4]] on your desktop or laptop. This tutorial uses QGIS 3.23. Once you have selected the version you wish to download based on your operating system, follow the guide that is installed in the package. With QGIS now installed on your computer and a proper path for accessing the application on your hard drive, you are now able to start the tutorial!


Data

The data used in this tutorial is monthly climate summaries from Statistics Canada, which publishes extensive and easily accessible data for all provinces and territories in Canada. For more information about the data, visit the "About the Data" page here [[5]]. This in-depth look at provincial weather will be an easily malleable data set to use for the tutorial. In this example, we will be looking at Alberta's average mean temperature. This will give us a well-distributed data set that we will be able to use to create an IDW model and help us calculate the approximate temperature values of areas that do not have weather stations.

Downloading the data

  1. First, set up a folder in your file directory for your project. This will be where you save all your data and your QGIS project
  2. Next, go to [[6]] and set the date to December of 2019
  3. Select your area of interest (for this assessment, Alberta was used as it has the most climate stations in the country)
  4. Select CSV as the data format and click "Download data" to start your download
  5. You can also download the Legend(txt) file as it will allow you to see what all the data is meant to represent
  6. Next, we will download our provincial boundary file from [[7]]
  7. Select your preferred language, the .shp file format, and provinces/territories under "Cartographic Boundary File"
  8. Next hit continue at the bottom of the page, this will redirect you to a new page with a link labelled "Archived – gpr_000b11a_e.zip (ZIP version, 40,968.0 kb)" click the link to download the .zip folder
Screen Shot 2021-12-23 at 10.47.38 AM.png
Screen Shot 2021-12-23 at 10.52.41 AM.png



Editing the data

With this data having so many variables, we need to edit it to make it easier to work with:

  1. Open your CSV file using a spreadsheet software like Excel
  2. Right-click on the "Clim_ID" column to select the entire row
  3. Use the sort/filter drop-down menu and filter the "Clim_ID" column from largest to smallest
  4. Select the rows with values that contain letters and delete them from your file. These rows are not needed and can create some issues when loading the data into QGIS
  5. Save your worksheet as a CSV in your project folder and close your spreadsheet software
Screen Shot 2021-12-23 at 11.07.44 AM.png



QGIS

Loading CSV File and Provincial Boundary File

  • Launch QGIS and create a new project file. Save your project to the folder you created at the start of the tutorial
  • At the top of your toolbar, click the plugin tab and click the "manage and install plugins" item.
  • Search for the "QuickMapServices" plugin in the pop-up window and install it to QGIS. Save your project, close and re-open the QGIS application to activate the plug-in
Plugin 1.png
Plugin 2.png
  • After reopening your project, click the Web tab on the menu, then QuickMapServices dropdown and select OSM standard. This will serve as a base map to your project
Plugin 3.png


  • Add in the monthly climate summary data by clicking on the layer tab in the menu, selecting "Add Layer" and clicking "Add Delimited Text layer"
CSVI 1.png


  • In the pop up window, click the 3 dots at the top right corner of the screen (highlighted in blue in the image below) and navigate to your project folder. Select the climate summary CSV file. In the Geometry definition option, set your x field to "Long" and your y field to "Lat" (highlighted in yellow) to set your coordinates
CSVI 2.png


  • Click on the layer tab in the menu, go to the "Add Layer" tab and select "Add Vector Layer"
VI 1.png


  • In the pop-up window, click the 3 dots at the top right corner of the screen (highlighted in blue in the image below) and navigate to your project folder. Select the boundary file with a .shp ending
VI 2.png


  • Right-click on the boundary layer and select "Open attribute table"
  • In the pop-up window, click the pencil (circled in yellow) at the top right of the window to begin editing. Select all layers except Alberta and click the "Delete Selected Feature" tool (circled in red) on the menu
AT 1.png


  • Right-click on the boundary and toggle editing to stop editing the layer. Select the "Save your Edits" option from the ensuing pop-up
  • The following step is to save both of your layers as individual files. If this is not done, they will have to be re-created each time you open your project. To do this, right-click on the layer, click "Export", then select "Save Feature As"
SVS 1.png


  • In the pop-up window, click the 3 dots (highlighted in blue) and navigate to your project folder. Give your feature an appropriate name, and then click "Okay"
  • Repeat this step for both the boundary and weather station layers
SVS 2.png




Interpolating data to create a Raster Surface layer

  • Click the processing tab or the gear icon in the menu
MENU 1.png


  • This will bring up a menu on the left side of the application with a search bar at the top of its menu. Click on the "Interpolation" row to open the sub-menu. Once you have located it, double-click "IDW Interpolation" (highlighted in yellow) to open the tool window
TB 1.png


  • In the new window, select the weather stations layer from the "Vector layer" drop-down. Next, select "Tm" from the "Interpolation attribute" drop-down to assign the mean temperature as the value we are interpolating
  • Click the plus button (highlighted in yellow) to add the stations layer to the "Vector layer" list. Select the "points" tab under the "Type" drop-down
IDW 1.png


  • Click the drop-down by the "Extent" option to limit the extent of the interpolation. Click "Calculate from Layer" and select your boundary file as the extent
IDW 2.png


  • Once the processing is complete, the result should resemble the image below
IDW 3.png



Clipping Interpolation Surface to create a final raster layer

  • Click the "Raster" tab in the menu and select "Extraction", then "Clip Raster by Mask Layer"
Clip 1.png


  • In the window, select your interpolated layer as the "Input Layer". Next, select the boundary layer as the "Mask Layer"
Clip 2.png


  • Right-click on the new layer and select the "Properties" button at the bottom of the pop-up menu
  • In the new window, change the "Render type" to "Singleband pseudocolor" using the drop-down menu (highlighted in yellow). Next, select the red to blue colour ramp using the "Color ramp" drop-down and selecting "All Color Ramps". Invert the colour ramp so that red represents higher temperatures and blue colder using the "Invert Color Ramp" function in the "Color ramp" drop-down (highlighted in blue)
Col 1.png


  • Next, export the layer by right-clicking and selecting "Export" and "Save Feature As".
  • Set the "Format" to GeoTIFF and click the three dots to navigate to your project folder. Name your file, then click "OK" to save
Clip 3.png


  • Your project should look like the image below
Col 2.png



  • Once this is completed, the tutorial is over and you successfully ran an interpolation on open-source software! Thank you for following along, and we hope that this has been helpful - Pierce and Alex




Resources

Boundary files. (n.d.). Retrieved December 23, 2021, from https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2011-eng.cfm

Kriging Interpolation—The Prediction Is Strong in this One. (2017, February 4). GIS Geography. https://gisgeography.com/kriging-interpolation-prediction/

Types of Interpolation—Advantages and Disadvantages. (n.d.). GIS Resources. Retrieved December 22, 2021, from https://www.gisresources.com/types-interpolation-methods_3/

Media, G. R. is an initiative of S. (2013, October 4). Interpolation. GIS Resources. https://www.gisresources.com/gis_interpolation_techniques_2/

Canada, E. and C. C. (2011, October 31). Monthly Climate Summaries—Climate—Environment and Climate Change Canada. https://climate.weather.gc.ca/prods_servs/cdn_climate_summary_e.html

Meng, Q., Liu, Z., & Borders, B. E. (2013). Assessment of regression kriging for spatial interpolation – comparisons of seven GIS interpolation methods. Cartography and Geographic Information Science, 40(1), 28–39. https://doi.org/10.1080/15230406.2013.762138

Li, J., & Heap, A. D. (2014). Spatial interpolation methods applied in the environmental sciences: A review. Environmental Modelling & Software, 53, 173–189. https://doi.org/10.1016/j.envsoft.2013.12.008