0

I have a gpkg file where I have the coordinates of the 1x1 km grid. See the below sample picture.

enter image description here

I am trying to extract the coordinates (latitude & longitude) of all the 1x1 grid cells from my gpkg file.

Any hints here?

1 Answer 1

1

It depends on what you are trying to achieve. If you are looking for the coordinates of each corner of every cell, that is different than looking for the central coordinate of each cell.

I am going to assume you meant the central coordinate of each cell. In which case, one possible solution is as follows:

  1. Run the 'Centroids' tool on the layer of cells. This will produce a layer of single points representing the center of each cell.
  2. Then run the 'Add geometry attributes' tool on the resulting centroids layer, which will produce a new layer where each cell centroid has two additional columns added to the attribute table: the x-coordinate (longitude) and y-coordinate (latitude).
  3. Assuming you want this information in a table you can then play around with in Excel, export the resulting layer to a CSV file.

Important point to remember, the gpkg layer must be in a geographic CRS (in degrees), not projected, or your resulting x and y coordinates will not be lat/lon but Northings and Eastings.

4
  • Thank you very much. It worked perfectly. Yes, I was aiming for the central coordinate of each cell. Commented May 6 at 20:01
  • I have a quick question. Is it possible to remove the distant part (far away) of the map? I can do it in Python, as I have a CSV file now. Can we do it in QGIS? Commented May 6 at 20:39
  • 1
    You may select the distant grid by drawing the polygon using the "Select Features by Polygon" tool and delete the selected grid.
    – GIStree
    Commented May 7 at 6:26
  • @GIStree Perfect! Commented May 7 at 12: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.