Feature request #4078
Enable CRS conversion in field calculator
|Pull Request or Patch supplied:||No||Resolution:||fixed/implemented|
|Easy fix?:||No||Copied to github as #:||14061|
When using functions like $x, $y, xat(n) and yat(n) the coordinate is returned in the layer CRS.
It would be useful to also be able to get these in the Project CRS or another specified CRS. I understand this is a very popular ability in Mapinfo ;)
I'm assigning low priority because I think it is currently possible to workaround it by making a copy of the file in the other CRS.
#6 Updated by Médéric RIBREUX over 4 years ago
- Resolution set to fixed/implemented
- Status changed from Open to Closed
Hello, bug triage...
there is now a transform function in QGIS expressions that make the CRS conversion. You can use it like this to get the x coordinate of a point converted from EPSG:4326 to EPSG:2154:
x(transform($geometry, 'EPSG:4326', 'EPSG:2154'))
For xat (which is replaced with point_n):
x(transform(point_n($geometry, 3), 'EPSG:4326', 'EPSG:2154'))
I am now closing this feature request as there is a way to make the CRS conversion directly from the expression dialog.