I have overlaid a 10m x 10m grid onto a UK Ordnance Survey raster map. I have set both raster and vector maps to the same CRS, (OSGB 1936 British National Grid; ESPG:27700). I have a csv file containing biological survey information gathered at differing 10m quadrats. I want to join the survey data to my 10m x 10m grid as a new layer. However, when I open the attribute table, only Y co-ordinate data is shown. How do I make QGIS show both x and y co-ord attributes for a grid so that I can import my tabular information?
2 Answers
After activating edit mode with the pencil icon, you can add a new field with the field calculator (the symbol bottom right).
Enter a new field name, data type real
, and select $x
from the Geometry node.
-
Thanks Andre. This does produce an X co-ord field in the attribute table, but all the fields have NULL value? Is there another step required? Commented Jul 4, 2013 at 15:45
-
You are right, $x and $y are for point geometries. Depending on what you want, you can create centroids from your grid (see gis.stackexchange.com/questions/45243/…) and use $x and $y, or convert your polygons to lines, and use xat(0) and yat(0) for the coordinates of the first point. By the way, QGIS vector grid tool creates polygon shapefiles with min and max coordinates in the attribute table.– AndreJCommented Jul 4, 2013 at 17:00
-
Hmmm, the 10 x 10m grid was built using the vector grid tool which makes me wonder why both x and y co-ords are not displayed as a default setting? Commented Jul 4, 2013 at 18:47
-
Did you create lines or polygons? Only with polygons you get xmin/max and ymin/max. If you have lines, you can use xat(0). The COORD field of the lines grid is only good for labelling.– AndreJCommented Jul 4, 2013 at 19:17
-
I went back and drew the grid as a polygon which gave the co-ords that I was after. Thanks Commented Jul 12, 2013 at 9:17
I went back and drew the grid as a polygon which gave the co-ords that I was after.