0

I have created a simple shapefile layer (points) within my project. When I created the layer I added two fields 'Eastings' and 'Northings' but these don't seem to be used for storing the locational information for each point.

Where is the locational information stored and how can I access it?

Vince
  • 20,017
  • 15
  • 45
  • 64
Packwood
  • 135
  • 4

1 Answers1

2

A shapefile is a set of files on disk, and QGIS reads and writes to shapefiles (and other spatial formats). Within QGIS what you have is a vector layer - this is any layer with points, lines, or polygons (in contrast to a gridded raster layer).

The information describing the geometry of the points, lines, or polygons is stored in the geometry of the layer, and only additional attributes of those features are visible in the "Attribute Table" dialog. Your "Eastings" and "Northings" are attributes.

So at one level, the geometry information is stored in memory in a data structure to which you don't have very direct access to.

There are functions for taking a Point vector layer and creating two new columns with the coordinates of each point as attributes, and its also possible to take two attribute columns and create point geometries with them. Because vector geometries get more complex for lines and polygons, its not practical to store them as columns in a rectangular table, although there are binary and text-based formats for this (WKB and WKT) which you can create columns of from vector layer geometries.

The geometry of each feature of a vector layer can be accessed from the layer using Python code within QGIS if you need to do anything to the geometry that can't be done with existing processing routines. But this might be a bit advanced for now...

Spacedman
  • 63,755
  • 5
  • 81
  • 115
  • Thanks, that answers my question in a really helpful way. My supplementary question then is: Can I export my layer data including the geometry information? – Packwood Oct 04 '23 at 21:02
  • 1
    If you mean geometry information in a human readable format, see https://gis.stackexchange.com/questions/359940/adding-x-y-coordinates-to-attribute-table-in-qgis. For the machines geometries are exported automatically when you save data into any GIS format. – user30184 Oct 04 '23 at 21:23
  • 1
    Yes. If you save as a shapefile the geometry is stored in binary format in the .shp and .shx files. Most GIS formats are binary and its hard to "see" the geometry without some code to interpret the binary, but if you save as geoJSON you can see the geometry as text in the file if you open it in a text editor. – Spacedman Oct 05 '23 at 04:59