Analyse des Points dans le Polygone¶
Note
In QGIS3, you can perform this analysis using the Join attributes by location (summary)
tool in the Processing Toolbox. Use the polygon layer as the Input Layer, the point layer as the Join layer and count
as the Summaries to calculate. See Performing Spatial Joins (QGIS3) tutorial for step-by-step instructions.
La puissance de QGIS réside dans l’analyse combinée de plusieurs sources de données. La réponse à la question que vous vous posez en fréquemment dispersée dans plusieurs couches qu’il vous faut analyser pour extraire et compiler cette information. Un exemple de ce type d’analyse est Points dans le Polygone. Si vous disposez d’une couche de polygones et d’une couche de points et que vous voulez savoir combien de points sont à l’intérieur du polygone, vous pouvez utiliser cette méthode d’analyse.
Description de l’exercice¶
A partir des positions de tous les tremblements de terre d’importance significative connus, nous allons essayer de trouver quel pays à le plus grand nombre de séismes.
Récupérer les données¶
Nous allons utiliser la couche issue du centre de données géophysiques nationales de la NOAA Base de données des séismes significatifs comme couche représentant les séismes majeurs. Téléchargez Données des séismes séparées par des tabulations .
Natural Earth has Admin 0 - Countries dataset. Download the countries
For convenience, you may directly download a copy of the dataset from the link below:
Data Sources: [NCEI] [NATURALEARTH]
Procédure¶
Open
and browse to the downloadedsignif.txt
file.
Since this is a tab-delimited file, choose Tab as the File format. The X field and Y field would be auto-populated. Click OK.
Note
You may see some error messages as QGIS tries to import the file. These are valid errors and some rows from the file will not be imported. You can ignore the errors for the purpose of this tutorial.
As the earthquake dataset has Latitude/Longitude coordinates, choose WGS 84 EPSG:436 as the CRS in the Coordinate Reference System Selector dialog.
The earthquake point layer would now be loaded and displayed in QGIS. Let’s also open the Countries layer. Go to
. Browse to the downloadedne_10m_admin_0_countries.zip
file and click Open. Select thene_10m_admin_0_countries.shp
as the layer in the Select layers to add… dialog.
Click on
In the pop-up window, select the polygon layer and point layer respectively. Name the output layer as
earthquake_per_coutry.shp
and Click OK.
Note
Be patient after clicking OK, QGIS may take upto 10 minutes to calculate the results.
When asked whether you want to add the layer to TOC, click Yes.
You will see a new layer is added to the table of content. Open the attribute table by right-clicking on the layer and selecting Open Attribute Table.
In the attribute table, you will notice a new field named
PNTCNT
. This is the count of number of points from the earthquakes layer that fall within each polygon.
To get our answer, we can simply sort the table by
PNTCNT
field and the country with highest count will be our answer. Click 2-times on thePNTCNT
column to get it sorted in descending order. Click on the first row to select it and close the Attribute Table.
Back in the main QGIS window, you will see one feature highlighted in yellow. This is the feature linked to the selected row in the attribute table which had the highest number of points. Select the Identify tool and click on that polygon. You can see that the country with the highest number of Significant earthquakes is China.
We determined from the simple analysis of 2 datasets that China has had the highest number of major earthquakes. You may refine this analysis further by taking into consideration the population as well as the size of the country and determine which is the most adversely affected country by major earthquakes.
If you want to report any issues with this tutorial, please comment below. (requires GitHub account)