Skip to main content
use @layer_crs as @map_crs isn't a known variable in the QGIS 3.22.6 field calculator, remove redundant make_point(x(), y())
Source Link

Inserting new fields with the field calculator and the expression $x and $y on the layer with your centroids should do the job. If you use the polygon layer of your lakes, you might include there lat/lon in the attribute table directly with x(centroid($geometry)) resp. y(centroid($geometry)).

If your layer is not in EPSG 4326, you can use this expression to reproject the coordinates and get lat/lon-coordinates (replace XXXX with the EPSG-code of your CRS):. For latitude

xy(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

and for longitude

y(transform( make_point (x(centroid($geometry)),ytransform(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

Or even better: include the EPSG-code of your project with the corresponding variable, so you don't even have to know about what EPSG you are using and the result is always correct, even when changing the project-CRS CRS. This expressionThese expressions should work without any changes with whatever vector layer you use:

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs @layer_crs, 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs @layer_crs, 'EPSG:4326'))

Inserting new fields with the field calculator and the expression $x and $y on the layer with your centroids should do the job. If you use the polygon layer of your lakes, you might include there lat/lon in the attribute table directly with x(centroid($geometry)) resp. y(centroid($geometry)).

If your layer is not in EPSG 4326, you can use this expression to reproject the coordinates and get lat/lon-coordinates (replace XXXX with the EPSG-code of your CRS):

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

Or even better: include the EPSG-code of your project with the corresponding variable, so you don't even have to know about what EPSG you are using and the result is always correct, even when changing the project-CRS. This expression should work without any changes with whatever vector layer you use:

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))

Inserting new fields with the field calculator and the expression $x and $y on the layer with your centroids should do the job. If you use the polygon layer of your lakes, you might include there lat/lon in the attribute table directly with x(centroid($geometry)) resp. y(centroid($geometry)).

If your layer is not in EPSG 4326, you can use this expression to reproject the coordinates and get lat/lon-coordinates (replace XXXX with the EPSG-code of your CRS). For latitude

y(transform(centroid($geometry), 'EPSG:XXXX', 'EPSG:4326'))

and for longitude

x(transform(centroid($geometry), 'EPSG:XXXX', 'EPSG:4326'))

Or even better: include the EPSG-code of your project with the corresponding variable, so you don't even have to know about what EPSG you are using and the result is always correct, even when changing the project CRS. These expressions should work without any changes with whatever vector layer you use:

x(transform(centroid($geometry), @layer_crs, 'EPSG:4326'))
y(transform(centroid($geometry), @layer_crs, 'EPSG:4326'))
added 432 characters in body
Source Link
Babel
  • 74.9k
  • 15
  • 87
  • 227

Inserting new fields with the field calculator and the expression $x and $y on the layer with your centroids should do the job. If you use the polygon layer of your lakes, you might include there lat/lon in the attribute table directly with x(centroid($geometry)) resp. y(centroid($geometry)).

If your layer is not in EPSG 4326, you can use this expression to reproject the coordinates and get lat/lon-coordinates (replace XXXX with the EPSG-code of your CRS):

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

Or even better: include the EPSG-code of your project with the corresponding variable, so you don't even have to know about what EPSG you are using and the result is always correct, even when changing the project-CRS. This expression should work without any changes with whatever vector layer you use:

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))

Inserting new fields with the field calculator and the expression $x and $y on the layer with your centroids should do the job. If you use the polygon layer of your lakes, you might include there lat/lon in the attribute table directly with x(centroid($geometry)) resp. y(centroid($geometry)).

If your layer is not in EPSG 4326, you can use this expression to reproject the coordinates and get lat/lon-coordinates (replace XXXX with the EPSG-code of your CRS):

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

Or even better: include the EPSG-code of your project with the corresponding variable, so don't even have to know about what EPSG you are using and the result is always correct, even when changing the project-CRS:

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))

Inserting new fields with the field calculator and the expression $x and $y on the layer with your centroids should do the job. If you use the polygon layer of your lakes, you might include there lat/lon in the attribute table directly with x(centroid($geometry)) resp. y(centroid($geometry)).

If your layer is not in EPSG 4326, you can use this expression to reproject the coordinates and get lat/lon-coordinates (replace XXXX with the EPSG-code of your CRS):

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

Or even better: include the EPSG-code of your project with the corresponding variable, so you don't even have to know about what EPSG you are using and the result is always correct, even when changing the project-CRS. This expression should work without any changes with whatever vector layer you use:

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))
added 432 characters in body
Source Link
Babel
  • 74.9k
  • 15
  • 87
  • 227

Inserting new fields with the field calculator and the expression $x and $y on the layer with your centroids should do the job. If you use the polygon layer of your lakes, you might include there lat/lon in the attribute table directly with x(centroid($geometry)) resp. y(centroid($geometry)).

If your layer is not in EPSG 4326, you can use this expression to reproject the coordinates and get lat/lon-coordinates (replace XXXX with the EPSG-code of your CRS):

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

Or even better: include the EPSG-code of your project with the corresponding variable, so don't even have to know about what EPSG you are using and the result is always correct, even when changing the project-CRS:

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))

Inserting new fields with the field calculator and the expression $x and $y on the layer with your centroids should do the job. If you use the polygon layer of your lakes, you might include there lat/lon in the attribute table directly with x(centroid($geometry)) resp. y(centroid($geometry)).

If your layer is not in EPSG 4326, you can use this expression to reproject the coordinates and get lat/lon-coordinates (replace XXXX with the EPSG-code of your CRS):

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

Inserting new fields with the field calculator and the expression $x and $y on the layer with your centroids should do the job. If you use the polygon layer of your lakes, you might include there lat/lon in the attribute table directly with x(centroid($geometry)) resp. y(centroid($geometry)).

If your layer is not in EPSG 4326, you can use this expression to reproject the coordinates and get lat/lon-coordinates (replace XXXX with the EPSG-code of your CRS):

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))), 'EPSG:XXXX', 'EPSG:4326'))

Or even better: include the EPSG-code of your project with the corresponding variable, so don't even have to know about what EPSG you are using and the result is always correct, even when changing the project-CRS:

x(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))

and

y(transform( make_point (x(centroid($geometry)),y(centroid($geometry))),  @map_crs , 'EPSG:4326'))
Source Link
Babel
  • 74.9k
  • 15
  • 87
  • 227
Loading