2

I have the following data in CSV format: latitude and longitude of the geolocation of different events, where they occurred, and different additional information. Each row is a different event with a different location or with the same. I also have a grid of cells.

The idea is to associated to each event with a cell according to their latitude and longitude. I would like to associate each point (each row) of the csv with a cell. Each point should get an additional attribute with the id of the cell. Not every cell in the grid have an event, so, this last cells should maintain without information, like missing or something.

10
  • 2
    You should not delete the old answer and create a new post as the old question already has an answer. Undelete the first question and delete this one.
    – Babel
    Jul 12, 2021 at 10:08
  • @Babel You are making me a mess. How can I undelete the before question? I said apologies for it. It is my first question here. I just put again the question because I could not receive more answers and I did not put my question clear. I should have had more careful with it. Please, let me maintain this question. I will not do it again.
    – OgeiD
    Jul 12, 2021 at 10:11
  • I voted to reopen the old questions. Let's see if there will be enough votes to do so, than I will post my answer there. You already have the grid and just want to know how to associate it's cells to the points? Or do you also need help creating the grid? Please always be as clear in your questions as possible. Posting a screenshot and stating what you already have, what you tried and at what point exactly you're stuck and how the result you want to achieve should look like helps a lot to understand where you need help.
    – Babel
    Jul 12, 2021 at 10:18
  • Thank you for your answer @Babel. I do not have the grid, I have just the CSV I mention in the question. I need to create the grid. I edited a bit more my question, probably now it is clearer.
    – OgeiD
    Jul 12, 2021 at 10:23
  • Even thought there will be enough votes, how can I undelete the question? I have been looking but I have not seen it anymore.
    – OgeiD
    Jul 12, 2021 at 10:25

1 Answer 1

1
  1. To create a grid: use Menu Vector / Research Tools / Create grid. Select rectangles (polygons), for the grid extent select the Africa-layer and set the horizontal and vertical distances (see screenshot 1).

  2. Once you have the grid, assign to each of your points the id of the grid-cell it lies within. Use Menu Processing / Toolbox / Join attributes by position, select the points and the grid as input and check the box to within.

You get a new layer - a copy of your initial points with additional attributes from the grid cell they lie within.

Screenshot 1: create a grid enter image description here

Screenshot 2: join attributes by position enter image description here

9
  • Thank you Babel, I will try to do it and I will let you know if it works!.
    – OgeiD
    Jul 12, 2021 at 11:19
  • I am trying to do it when you have tell me but I have a small problem. I have a layer of the of world and when I try to select just Africa it is a bit complicate because it includes the middle east. Do you know an easy way to do it? I am sorry but I am very new using QGIS. Thanks!
    – OgeiD
    Jul 12, 2021 at 13:43
  • On the other hand, when I select the distance, it does not appear for me "grad". I have just meters, kilometers, foots, miles and yards. What I should choose?
    – OgeiD
    Jul 12, 2021 at 13:48
  • 1
    For your question about selecting Africa: this is another question, you should post it here as another question and tell exactly what kind of data you have, what you've tried and where you're stuck. Post a screenshot if possible. If you want to create a grid in degrees, you should select a geographic CRS, e.g. EPSG:4326, see here: i.stack.imgur.com/OWd4H.png
    – Babel
    Jul 12, 2021 at 13:53
  • 1
    Yes, probably in this case the result will be the same (I guess). The points both are within and intersect a polygon cell. If you have two polygons (like a buffer around the points), these might intersect the grid-cell, but are not (completely) within.
    – Babel
    Jul 13, 2021 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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