4

I have some data as .shp (polygone representing Antarctica continent). I would like to know if there is a way to create a raster containing the lat/lon for each grid point ... Has somebody here tried to to that?

  • Please clarify what you mean by "each grid point". You have a polygon of Antarctica. Where does the grid come in? – Micha Nov 28 '16 at 17:46
  • If it is a Grid covering the Continent, use the "Polygon Centroid" Tool , and then convert that to a Raster... Could you show a picture of the Data? – user32496 Nov 28 '16 at 17:48
  • 1
    Ok to be clearer: i don't have any grid so far. When i look to my layer metadata I obtain: Number of points: 0 Number of centroids: 1 Number of lines: 0 Number of boundaries: 2 Number of areas: 2 Number of islands: 2... So, now i've got a nice raster ;) My question was really not clear ... I'll give it another try: A raster is a layer composed by pixels right ? How can I know the lat/lon of each pixel of my raster ? Is there a way to save the raster as a .csv / .txt file ? – P. Huot Nov 29 '16 at 9:43
1

Based on your description above, you have a polygon layer (not a raster). You can easily make a regular grid covering that polygon with the QGIS tool "Vector->Research Tools->Vector Grid". Then, as GISJohnECS explained, you can get the centroids of each grid cell. This will create a third vector points layer. Finally, open the Field Calculator for this point layer, and use the geometry functions $x and $y to add two columns for longitude and latitude. You can read some more details in the QGIS documentation. That will give you all the long/lats of each centroid of all the cells in your (vector) polygon grid.

However, can I suggest you explain what it is you're trying to do?

  • Well put, I am editing my question adding something to it, hoepfully one of our solutions is what he is looking for – user32496 Nov 30 '16 at 0:34
2

Perhaps add more detail to your question, a preview of your .shp file would be nice. Assuming your .shp is a polygon of Antarctica divided into grids, and you want the Lat/Lon of each grid, to convert into a raster, Use the Go to the menu -> Vector -> Geometry tools -> polygon centroid and create a centroid point layer.

And then use the Interpolation Plugin to convert your centroid file to a Raster, using whatever attribute value you wish. If the attribute value from your polygon file is not attributed to your Centroid Output, just use a spatial join

Adding on based on your comment, Micha has added an answer assuming you just meant you wanted the XY values from a vector grid, but, assuming you want XY values from a raster, here is my take from this Tutorial use the Regular points Tool found in Vector->Research Tools-> Regular Points this tool will get regular points in a grid format separated by a defined distance, if you want points in each grid you can try define the distance as the width of each pixel understand if you have a high resolution raster it may crash, normally I just define a number of points like 100000 or something

You have your raster: enter image description here

Run the Regular Points Tool: enter image description here

Heres the output: enter image description here

And then save this layer as a CSV and have the geometry as X,Y enter image description here

This will give you X,Y locations of each point that was generated, that may not be from each pixel though... As i mentioned this assumes you really want the XY values for pixels... But also read Michas Answer to see if thats what you wanted

  • So, now i've got a nice raster, thanks ;) My question was really not clear ... I'll give it another try: A raster is a layer composed by pixels right ? How can I know the lat/lon of each pixel of my raster ? And write those lat/lon in .txt/.csv file ? – P. Huot Nov 29 '16 at 12:32
  • @P.Huot I think I may have a solution, once I finish work I will post one for you, unless someone else jumps in first. – user32496 Nov 29 '16 at 17:11
  • @P.Huot I edited, let me know if it helps otherwise Mocha has added an answer – user32496 Nov 30 '16 at 0:52
  • Hi, thanks a lot, i can't try it right now but it seems to be what i wanted to do. If i fail at this method, there is still Micha's one ;) – P. Huot Nov 30 '16 at 9:16

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.