Joining attributes in CSV by location using QGIS

africaoverlapping-featurespoint-in-polygonqgisspatial-join

I have a shapefile which divides Africa in cells of 0.5×0.5 decimal degrees. This documents provides the longitude, latitude of the centroid of the cell and a unique identified of each cell.

On the other hand, I have a CSV file with different observations and different variables, including longitude and latitude among the variables. I transform this as a GeoPackage and they appears as a point in the QGIS.

enter image description here

Taking advantage of the latitude and longitude of the CSV file, I use a "Join Attributed by Location". Input Layer: my shp file; Join layer: my GeoPackage (before my CSV file); Geometric Predicate: I use the option "Intersects".

My main objective is to add to the grid cell the number of events of the CSV. For example, if according to the longitude and latitude of the CSV file, there are five events in a grid cell, I would like to obtain five observations in this grid cell. If I do not have any observation in one grid cell, the variables remain missing.

I do it without any problem. However, when I check the CSV that I export after doing the join, the number of observations are lower.

How is it possible? What I am doing wrong?

It should be greater than my original CSV, because it has to include all the observations of the CSV plus the grid cells that does not have any event.

I show the following picture. It is Africa divided in the grid cell and the points are the CSV. So, I would like to join the points to the grid cell. My version of QGIS is 3.20.1

This is the screen shot of my GeoPackage file (before CSV)

enter image description here

This is the screenshot of my shapefile:

enter image description here

Best Answer

I guess you should use the tool "Join attributes by location (summary)".

Here is a picture explaining quickly how you should proceed:

enter image description here

Differences between "join by location (summary)" and "join by location":

enter image description here