3

I have created a grid map as a shapefile. I have added a point layer that includes “species name”, coordinates and etc. I put a part of it below. enter image description here

Now, My problem is, when I use “count points in polygon” tool, the “species name” is missed and I cant see the “species name” in the attribute table. This tool counts the number of points only such as this: Left bottom right top number of point enter image description here

If I want to ask my question in another way, How to export the species names which fall into each cell. It is very important for us to know what species are inside each cell. enter image description here

1
  • Base on the left, bottom, top and right columns in your t5 layer, shown in the join results above, it looks like you have created a research grid using longitude and latitude intervals. This means the cells in your research grid are not equal areas, if that matters for how you are going to use your data.
    – hgb
    Commented Apr 3, 2022 at 14:57

2 Answers 2

4

On the grid layer, create a new attribute with Field calculator and the following expression. It generates you a text field for each grid cell, listing the species that are located in this cell.

Be sure to set Output field type to Text (string) and set an Output field length long enough to fit the whole list.

array_to_string (
     array_distinct( 
        overlay_contains( 
            'layer_species',  -- adapt the layer name
            "species"  -- adapt the name of the attribute
        )
    )
)

The expression used as a dynamic label: the black labels indicate which species (red dots with red labels) are inside each cell. Duplicates are removed to get just a list of the names of species that appear inside the cell:

enter image description here

3

One way of doing this:

  1. First run Join Attributes by Location (vector menu>Data Management Tools) - this will create a memory layer called Joined Layer.
  2. Then save Joined Layer as a geopackage. In the screenshot below it is called points_by_grid
  3. Connect to the new geopackage using the DB Manager and use a sql expression like this: enter image description here
2
  • Thank You... it is solved by this way.
    – Sina Kh.
    Commented Apr 3, 2022 at 15:54
  • 1
    If this answered your question, please accept it using the checkmark to the left. It is a way of thanking @Aquamarine by awarding them reputation and it will help future readers of your question.
    – Matt
    Commented Apr 4, 2022 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.