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?

  • Sorry, I should specify when I open the attribute table of the 10m x 10m grid shapefile, only the Y coordinate info is shown. – Ben Wells Jul 4 '13 at 14:24

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? – Ben Wells Jul 4 '13 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. – AndreJ Jul 4 '13 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? – Ben Wells Jul 4 '13 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. – AndreJ Jul 4 '13 at 19:17
  • I went back and drew the grid as a polygon which gave the co-ords that I was after. Thanks – Ben Wells Jul 12 '13 at 9:17

I went back and drew the grid as a polygon which gave the co-ords that I was after.

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.