|Inverse Distance Weighting (IDW) Interpolation using QGIS|
In this tutorial we will use a sample set of point locations to create a raster surface based on the data’s attribute values. To do this we will use the IDW interpolation method. Surface interpolation is used when you have data for certain locations and want to estimate the values in between each location. The output is a raster layer that contains a value everywhere within the extent of your data. The flow of this tutorial will be to open the points GIS data in QGIS, interpolate a raster surface from these points, and symbolize the layer to visualize the results.
Start by downloading the sample data here.
Open QGIS and click the “Add Vector Layer” button to load your annual_precipitation.shp shapefile.
First, let’s browse the attribute data to view the column we will be using to perform the interpolation. Open the attribute table by right-clicking the layer and choosing “Open attribute table”. You will see an attribute called “precip”. This represents the annual precipitation in millimeters. Each location has a precipitation value and we will be using this to interpolate values in between the points creating a continuous surface. Close the attribute table.
To create an IDW Layer in QGIS, go to the Plugins menu, then Interpolation > Interpolation.
Under the Input Vector layers select the points file “annual_precipitation”. Note that you can add multiple interpolation layers if desired and the interpolation will consider the data from all layers. Set “precip” as the Interpolation attribute and click the “Add” button to set the input attribute.
Also note that you can use the z-coordinate for the interpolation. This is the elevation of your data that is stored within the geometry itself and not in an attribute column. This is only possible if your GIS data is in 3 dimensions.
Under the Output Interpolation method select “Inverse Distance Weighting (IDW)”. Click the tool icon to define the settings for IDW. This will allow you to set the “Distance coefficient P”. Remember that IDW is based on the assumption that the further the surface gets from a point’s value the less similar it becomes. In other words, the surface values are determined by the influence of near points and less by distant points.
The Distance coefficient P is used to specify the rate of influence as distance increases. This is best explained by visualizing the output of 2 different IDW surfaces run at different coefficients.
The image below represents the analysis at a Distance coefficient P value of 1:
The following image illustrates the analysis at a Distance coefficient P value of 3:
As you can see, a larger coefficient means it takes a larger distance for the values of the surface to become dissimilar from nearby points. A small coefficient means the values of the surface will quickly change as distant increases. This can produce an abrupt change in values and is prone to the “bull’s-eye effect” creating circular regions in your surface. It is best to create a few different surfaces and adjust this number to suit your analysis. Set this value to 2.70.
Next we will set the Cellsize X and Cellsize Y. The Cellsize is used to specify the number of units to be included in each cell’s width and height. For example, setting the Cellsize X and Cellsize Y to 20 means each cell will represent 20 meters by 20 meters. We know our units are in meters because this data is projected using UTM coordinates.
Set the Cellsize X and Cellsize Y to 20. The Number of columns and Number of rows will be auto adjusted according to the Cellsize. For a higher resolution output, reduce the cellsize/increase the number of rows and columns.
X min, X max, Y min, Y max are used to set the extent of the generated surface and are default set to the extent of the vector input layer. Leave this as is.
Finally browse to a location to store your output and name your IDW file. Click OK to run the interpolation.
The output will appear as a single band grey raster layer. You will need to symbolize it to visualize the results. For a quick and effective way to visualize your interpolation, choose “Pseudocolor” for the Color map in the layers properties, under symbology.
Learn more about how to set the symbology for your interpolated IDW layer by following our tutorial “Single Band Raster Layer Symbology in QGIS”.