With QGIS 3.24.1-Tisler on Mac, I want to get a list of lat/long coordinates for the Alaska sample data that comes with QGIS.
I followed the instructions at https://gis.stackexchange.com/a/64700, with the only difference being that the field calculator only allowed me 3 decimal places rather than the 6 the answer calls for. As per the referenced answer:
- Export an Alaska layer as alaska_shape of type ESPG:4326 - WGS 84
- Open the Attribute Table for the new layer
- Open the Field Calculator
- Added field
"degx"
, Decimal (real), Expression$x
(from Geometry) - Click Ok. Repeat step 3
- Add field
"degy"
, Decimal (real), Expression$y
(from Geometry) - Click Ok
I end up with:
with the two added fields being NULL
.
When I click to update all, with the hope that this will calculate and update the cells, I get:
An error occurred while evaluating the calculation string: No root node! Parsing failed?
Also, I can't seem to find a way to edit the field definitions once the fields have been created.
x
andy
of the centroid of the polygon by usingx(centroid($geometry))
andy(centroid($geometry))
.