23.1.5. Interpolazione

23.1.5.1. Mappa di concentrazione (stima kernel di densità)

Crea un raster di densità (mappa di concentrazione) da vettore in ingresso usando la stima kernel di densità.

La densità è calcolata basandosi sul numero di punti in una posizione, con un numero di punti raggruppati maggiore risulta un valore maggiore. Le mappe di concentrazione permettono di identificare facilmente gli hotspots e i raggruppamenti di punti.

23.1.5.1.1. Parametri

Etichetta

Nome

Tipo

Descrizione

Vettore di punti

IN INGRESSO

[vettore: punto]

Vettore di punti da usare per la mappa di concentrazione

Raggio

RAGGIO

[numero]

Predefinito: 100.0

La mappa di concentrazione usa il raggio (o la larghezza di banda del kernel) in unità di mappa. Il raggio specifica la distanza attorno a un punto in cui verrà percepita l’influenza del punto. Valori maggiori determinano una maggiore uniformità, ma valori più piccoli possono mostrare dettagli più fini e variazioni della densità dei punti.

Dimensione del raster in uscita

DIMENSIONE DEL PIXEL

[numero]

Predefinito: 0.1

La dimensione del pixel del raster in uscita nell’unità del layer.

Nelle GUI, la grandezza può essere specificata dal numero di righe (Numero di righe) / colonne (Numero di colonne) o la dimensione dei pixel( Dimensione pixel X / Dimensione pixel Y). Aumentando il numero di righe o colonne diminuirà la dimensione della cella e aumenterà la dimensione del file di output. I valori in Righe,``Colonne``,``Dimensione pixel X`` e Dimensione pixel Y sono aggiornati simultaneamente, quindi raddoppiando il numero di righe raddoppierà automaticamente il numero di colonne e anche le dimensioni delle celle saranno dimezzate. L’area geografica del raster in uscita rimarrà la stessa (approssimativamente).

Radius from field

Optional

RADIUS_FIELD

[tablefield: numeric]

Sets the search radius for each feature from an attribute field in the input layer.

Weight from field

Optional

WEIGHT_FIELD

[tablefield: numeric]

Allows input features to be weighted by an attribute field. This can be used to increase the influence certain features have on the resultant heatmap.

Kernel shape

KERNEL

[numero]

Predefinito: 0

Controls the rate at which the influence of a point decreases as the distance from the point increases. Different kernels decay at different rates, so a triweight kernel gives features greater weight for distances closer to the point then the Epanechnikov kernel does. Consequently, triweight results in “sharper” hotspots and Epanechnikov results in “smoother” hotspots.

There are many shapes available (please see the Wikipedia page for further information):

  • 0 — Quartic

  • 1 — Triangular

  • 2 — Uniform

  • 3 — Triweight

  • 4 — Epanechnikov

Decay ratio (Triangular kernels only)

Optional

DECAY

[numero]

Default: 0.0

Can be used with Triangular kernels to further control how heat from a feature decreases with distance from the feature.

  • A value of 0 (=minimum) indicates that the heat will be concentrated in the center of the given radius and completely extinguished at the edge.

  • A value of 0.5 indicates that pixels at the edge of the radius will be given half the heat as pixels at the center of the search radius.

  • A value of 1 means the heat is spread evenly over the whole search radius circle. (This is equivalent to the ‘Uniform’ kernel.)

  • A value greater than 1 indicates that the heat is higher towards the edge of the search radius than at the center.

Output value scaling

OUTPUT_VALUE

[numero]

Default: Raw

Allow to change the values of the output heatmap raster. One of:

  • 0 — Raw

  • 1 — Scaled

Heatmap

LIVELLO IN USCITA

[raster]

Default: [Save to temporary file]

Specify the output raster layer with kernel density values. One of:

  • Salva come File Temporaneo

  • Salva come File…

La codifica del file può anche essere cambiata qui.

23.1.5.1.2. In uscita:

Etichetta

Nome

Tipo

Descrizione

Heatmap

LIVELLO IN USCITA

[raster]

Raster layer with kernel density values

23.1.5.1.3. Example: Creating a Heatmap

For the following example, we will use the airports vector point layer from the QGIS sample dataset (see Dati campione). Another excellent QGIS tutorial on making heatmaps can be found at http://qgistutorials.com.

In Figure_Heatmap_data_processing, the airports of Alaska are shown.

../../../../_images/heatmap_start.png

Fig. 23.2 Airports of Alaska

  1. Open the Heatmap (Kernel Density Estimation) algorithm from the QGIS Interpolation group

  2. In the Point layer selectString field, select airports from the list of point layers loaded in the current project.

  3. Change the Radius to 1000000 meters.

  4. Change the Pixel size X to 1000. The Pixel size Y, Rows and Columns will be automatically updated.

  5. Click on Run to create and load the airports heatmap (see Figure_Heatmap_created_processing).

../../../../_images/heatmap_dialog.png

Fig. 23.3 The Heatmap Dialog

QGIS will generate the heatmap and add it to your map window. By default, the heatmap is shaded in greyscale, with lighter areas showing higher concentrations of airports. The heatmap can now be styled in QGIS to improve its appearance.

../../../../_images/heatmap_loaded_grey.png

Fig. 23.4 The heatmap after loading looks like a grey surface

  1. Open the properties dialog of the heatmap_airports layer (select the layer heatmap_airports, open the context menu with the right mouse button and select Properties).

  2. Select the Symbology tab.

  3. Change the Render type selectString to “Singleband pseudocolor”.

  4. Select a suitable Color ramp selectString, for instance YlOrRd.

  5. Click the Classify button.

  6. Press OK to update the layer.

The final result is shown in Figure_Heatmap_styled_processing.

../../../../_images/heatmap_loaded_colour.png

Fig. 23.5 Styled heatmap of airports of Alaska

23.1.5.1.4. Python code

Algorithm ID: qgis:heatmapkerneldensityestimation

import processing
processing.run("algorithm_id", {parameter_dictionary})

The algorithm id is displayed when you hover over the algorithm in the Processing Toolbox. The parameter dictionary provides the parameter NAMEs and values. See Usare gli algoritmi di Processing dalla console dei comandi for details on how to run processing algorithms from the Python console.

23.1.5.2. IDW Interpolation

Generates an Inverse Distance Weighted (IDW) interpolation of a point vector layer.

Sample points are weighted during interpolation such that the influence of one point relative to another declines with distance from the unknown point you want to create.

The IDW interpolation method also has some disadvantages: the quality of the interpolation result can decrease, if the distribution of sample data points is uneven.

Furthermore, maximum and minimum values in the interpolated surface can only occur at sample data points.

23.1.5.2.1. Parametri

Etichetta

Nome

Tipo

Descrizione

Input layer(s)

INTERPOLATION_DATA

[stringa]

Vector layer(s) and field(s) to use for the interpolation, coded in a string (see the ParameterInterpolationData class in InterpolationWidgets for more details).

The following GUI elements are provided to compose the interpolation data string:

  • Vector layer [vector: any]

  • Interpolation attribute [tablefield: numeric]: Attribute to use in the interpolation

  • Use Z-coordinate for interpolation [boolean]: Uses the layer’s stored Z values (Default: False)

For each of the added layer-field combinations, a type can be chosen:

  • Points

  • Structured lines

  • Break lines

In the string, the layer-field elements are separated by '::|::'. The sub-elements of the layer-field elements are separated by '::~::'.

Distance coefficient P

DISTANCE_COEFFICIENT

[numero]

Default: 2.0

Sets the distance coefficient for the interpolation. Minimum: 0.0, maximum: 100.0.

Extent (xmin, xmax, ymin, ymax)

ESTENSIONE

[estensione]

Extent of the output raster layer. You have to declare the output extent by either choosing it from the map canvas, selecting it from another layer or type it manually.

Dimensione del raster in uscita

DIMENSIONE DEL PIXEL

[numero]

Predefinito: 0.1

La dimensione del pixel del raster in uscita nell’unità del layer.

Nelle GUI, la grandezza può essere specificata dal numero di righe (Numero di righe) / colonne (Numero di colonne) o la dimensione dei pixel( Dimensione pixel X / Dimensione pixel Y). Aumentando il numero di righe o colonne diminuirà la dimensione della cella e aumenterà la dimensione del file di output. I valori in Righe,``Colonne``,``Dimensione pixel X`` e Dimensione pixel Y sono aggiornati simultaneamente, quindi raddoppiando il numero di righe raddoppierà automaticamente il numero di colonne e anche le dimensioni delle celle saranno dimezzate. L’area geografica del raster in uscita rimarrà la stessa (approssimativamente).

Interpolated

LIVELLO IN USCITA

[raster]

Default: [Save to temporary file]

Raster layer of interpolated values. One of:

  • Salva come File Temporaneo

  • Salva come File…

La codifica del file può anche essere cambiata qui.

23.1.5.2.2. In uscita:

Etichetta

Nome

Tipo

Descrizione

Interpolated

LIVELLO IN USCITA

[raster]

Raster layer of interpolated values

23.1.5.2.3. Python code

Algorithm ID: qgis:idwinterpolation

import processing
processing.run("algorithm_id", {parameter_dictionary})

The algorithm id is displayed when you hover over the algorithm in the Processing Toolbox. The parameter dictionary provides the parameter NAMEs and values. See Usare gli algoritmi di Processing dalla console dei comandi for details on how to run processing algorithms from the Python console.

23.1.5.3. TIN Interpolation

Generates a Triangulated Irregular Network (TIN) interpolation of a point vector layer.

With the TIN method you can create a surface formed by triangles of nearest neighbor points. To do this, circumcircles around selected sample points are created and their intersections are connected to a network of non overlapping and as compact as possible triangles. The resulting surfaces are not smooth.

The algorithm creates both the raster layer of the interpolated values and the vector line layer with the triangulation boundaries.

23.1.5.3.1. Parametri

Etichetta

Nome

Tipo

Descrizione

Input layer(s)

INTERPOLATION_DATA

[stringa]

Vector layer(s) and field(s) to use for the interpolation, coded in a string (see the ParameterInterpolationData class in InterpolationWidgets for more details).

The following GUI elements are provided to compose the interpolation data string:

  • Vector layer [vector: any]

  • Interpolation attribute [tablefield: numeric]: Attribute to use in the interpolation

  • Use Z-coordinate for interpolation [boolean]: Uses the layer’s stored Z values (Default: False)

For each of the added layer-field combinations, a type can be chosen:

  • Points

  • Structured lines

  • Break lines

In the string, the layer-field elements are separated by '::|::'. The sub-elements of the layer-field elements are separated by '::~::'.

Interpolation method

METHOD

[numero]

Predefinito: 0

Set the interpolation method to be used. One of:

  • Linear

  • Clough-Toucher (cubic)

Extent (xmin, xmax, ymin, ymax)

ESTENSIONE

[estensione]

Extent of the output raster layer. You have to declare the output extent by either choosing it from the map canvas, selecting it from another layer or type it manually.

Dimensione del raster in uscita

DIMENSIONE DEL PIXEL

[numero]

Predefinito: 0.1

La dimensione del pixel del raster in uscita nell’unità del layer.

Nelle GUI, la grandezza può essere specificata dal numero di righe (Numero di righe) / colonne (Numero di colonne) o la dimensione dei pixel( Dimensione pixel X / Dimensione pixel Y). Aumentando il numero di righe o colonne diminuirà la dimensione della cella e aumenterà la dimensione del file di output. I valori in Righe,``Colonne``,``Dimensione pixel X`` e Dimensione pixel Y sono aggiornati simultaneamente, quindi raddoppiando il numero di righe raddoppierà automaticamente il numero di colonne e anche le dimensioni delle celle saranno dimezzate. L’area geografica del raster in uscita rimarrà la stessa (approssimativamente).

Interpolated

LIVELLO IN USCITA

[raster]

Default: [Save to temporary file]

The output TIN interpolation as a raster layer. One of:

  • Salva come File Temporaneo

  • Salva come File…

La codifica del file può anche essere cambiata qui.

Triangulation

TRIANGULATION

[vector: line]

Default: [Skip output]

The output TIN as a vector layer. One of:

  • Skip Output

  • Crea livello temporaneo (TEMPORARY_OUTPUT)

  • Salva come File…

  • Salva come Geopackage…

  • Salva su Tabella PostGIS…

23.1.5.3.2. In uscita:

Etichetta

Nome

Tipo

Descrizione

Interpolated

LIVELLO IN USCITA

[raster]

The output TIN interpolation as a raster layer

Triangulation

TRIANGULATION

[vector: line]

The output TIN as a vector layer.

23.1.5.3.3. Python code

Algorithm ID: qgis:tininterpolation

import processing
processing.run("algorithm_id", {parameter_dictionary})

The algorithm id is displayed when you hover over the algorithm in the Processing Toolbox. The parameter dictionary provides the parameter NAMEs and values. See Usare gli algoritmi di Processing dalla console dei comandi for details on how to run processing algorithms from the Python console.