5 Data Interpolation using QGIS
5.1 Background
Data Interpolation is necessary for various reasons. We are familiar with the GIS point data obtain using traditional surveying. The elevation for points obtained by using survey equipment are not in regular grids. We need to convert the point-elevation data to raster for contouring and other analysis. Similarly, when we want to use land-based rainfall data observed by rainfall gauges, we need the data interpolation methods. This chapter will not go into details of data interpolation but provide a practice tutorial to learn about the data interpolation and its purpose.
5.2 Purposes of Data Interpolation
- Conversion of point data to raster data
- Finding appropriate rainfall station to be used for a given area
- Producing contour from the point data etc.
5.3 Data Preparation
Once upon a time, I had downloaded few rainfall data from DHM (Department of Hydrology and Meteorology, Nepal). The data can be found at this rainfall-data-link. Save this data in an appropriate directory.
5.3.1 Create point data from the rainfall data
Add the csv data to QGIS. The data is a non-spatial data with latitude and longitude values in the two corresponding fields. We can convert the data in a various ways. I will introduce following two ways.
- Using DB Manager
- Right click raindata layer \(\rightarrow\) Export as geopackage layer (e.g. rain_analyze.gpkg) in appropriate directory and appropriate layer name (e.g. raindata).
- In the dialog box change Geometry \(\rightarrow\) Automatic to No geometry
- The data has string columns. We need to convert strings (for latitude and longitude) column to decimal values.
- Open attribute table of rain (newly created gpkg layer) and open field calculator.
- Create new field x as decimal and set its value as
to_real(Longitude). - Similarly create new field y as decimal and set its value as
to_real(Latitude). - Open DB Manager and connect geopackage file just created.
- Open SQL window and run this SQL
select *, makepoint(x, y) xy from rain. A new column xy will be added. - Select Load as new layer and in the Geometry column select xy
- Export Query Layer as a new layer (e.g. rainxy) in the same geopackage file
- Using Processing Toolbox
- In the Processing Toolbox, select Create point layers from table under Vector Creation Tool
- Right click raindata layer \(\rightarrow\) Export as geopackage layer (e.g. rain_analyze.gpkg) in appropriate directory and appropriate layer name (e.g. raindata).
- In the dialog box change Geometry \(\rightarrow\) Automatic to No geometry
- The data has string columns. We need to convert strings (for latitude and longitude) column to decimal values.
- Open attribute table of rain (newly created gpkg layer) and open field calculator.
- Create new field x as decimal and set its value as
to_real(Longitude). - Similarly create new field y as decimal and set its value as
to_real(Latitude). - Input parameters:
- Select layer rain we created in above
- x as x-column and y as y-column
- In the output, select same geopackage file with a new layer (e.g. rainxy)
- Run the tool
5.3.2 Convert rain data to UTM projection (UTM 44N or UTM 45N)
5.4 Data Analysis
5.4.1 Thiessen Polygon (Voronoi Polygon)
- Search for Voronoi in the Processing Toolbox
- Run either of the following
- Vector Geometry \(\rightarrow\) Voronoi Polygon
- v.voronoi
- Alternatively we can use QGIS menu: Vector \(\rightarrow\) Geometry Tools \(\rightarrow\) Voronoi Polygons
5.4.1.1 What is voronoi (or Thiessen) Polygon?
5.4.2 IDW interpolation
Before starting any interpolation we need to convert the rainfall data (string) to real value. You can do it similar to the latitude and longitude done earlier. Let us convert rain_24 (24 hour cumulative rainfall) to float(real)
- Run Processing Toolbox \(\rightarrow\) Interpolation \(\rightarrow\) IDW Interpolation with the parameters shown in the following figure.
- Alternatively, we can use the tool v.surf.idw - The output is created as Raster data - We can create contour based on the output raster
5.4.3 RST Interpolation
- Run the tool v.surf.rst
- Use the input layer and field as before
- Keep the other parameters as default
- Skip output of not-needed values
5.4.4 TIN interpolation
- Run Processing Toolbox \(\rightarrow\) Interpolation \(\rightarrow\) TIN Interpolation with appropriate parameters
- Alternatively run Processing Toolbox \(\rightarrow\) SAGA \(\rightarrow\) Raster Spline Interpolation \(\rightarrow\) Thin Plate Spline with appropriate parameters