1

I need the exact values of longitude and latitude to do further calculations with those. Best case would be to have a list with all those dates and do the calculation with this.

I exported from OpenStreetMap to QGIS as a shapefile. Although the coordinates in the bottom bar are displayed on the map when you click on a point, there is no table (via attribute table) in which all coordinates are summarized.

1

Tested on QGIS 2.18 and QGIS 3.4

Additionally, I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...

Let's assume we have the following layer "some_points" with its attribute table, see image below.

input


With the following query, it is possible to create a "new" shapefile with requested attributes, i.e. "X" and "Y" separately and/or together as a tuple if prefered.

SELECT sp.*,
       ST_X(sp.geometry) AS X,
       ST_Y(sp.geometry) AS Y,
       '(' || ST_X(sp.geometry) || ', '|| ST_Y(sp.geometry) || ')' AS X_Y
FROM "some_points" AS sp

The output Virtual Layer with its Attribute table will look as following

output

7

The easiest way to add attributes containing the coordinates is using the add geometric properties-tool (vector -> geometry-tools). This adds the coordinates of the geometry using the CRS of the layer - but only if you have a point layer. For polygons the tool adds circumfence and area, for lines only the length.


You also may use the field calculator in order to add the coordinates of points, the whole geometry as well-known-text and even transform the coordinates to another CRS before adding them to the attribute table. All these functions are in the field calculator under geomtery and sufficiently described.

  • 2
    for polygon layer you can solve it by adding one more step - extracting nodes which creates a point layer from polygons and then add coordinates like you said for the point layer. – Juhele Jun 17 at 14:57
3

You may use some of the processing toolbox tool to add the coordinate (try SAGA>Vector point>tools>Add coordinate to point or Vector geometry>Add geometry attributes) or manually add a Latitude and Longitude field to the attribute table and calculate the value (use $x and $y as formula). This will give you shapefile with an attribute table including the Lat and Long (be carrefull, if you move some point the Lat and Long field are NOT automatically updated).

Another way to get the X/Y would be to export your data as CSV (right click on you layer Export>Save feature as) on the dialog you may choose to add the coordinate to the output

  • Thanks for you answers. I have currently the problem that I can't export the layer with the track points to CSV ? Are there any specific inputs I need to consider? I just selcected the geometry :AS_XY and lineformat: CRLF . Or which data format do I need to export it to a CSV ? – Martina Jun 22 at 8:52

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.