3

I'm using the expression:

x(transform($geometry, 'EPSG:32632', 'EPSG:3003'))

to add coordinates fields according to different CRS in a point layer. To obtain better accuracy i need to apply a Datum transformation (epsg:1662) in the CRS conversion. I have set the option "ask for default datum trasformation if several are avalaible" in Settings > Options that it should allow to select the datum transformation but using the expression in the field calculator this function does not seem to be available (the window does not appear).

How can I overcome this problem if possible or it would be better to create a custom CRS (how?) appplying the datum transformation to insert in the expression?

2

QGIS saves its coordinate systems in a database. In cases like EPSG:3003, it keeps several possible transformations but one by default. In the Settings > Options, you can tell QGIS to ask you which transformation to use instead of using the default transformation, or tell which is the default transformation you want to be used when reprojecting between two coordinate systems.

All datum transformations are performed with the WGS84 datum as an intermediary, so you could choose a transformation of the source system to WGS84 and another transformation of WGS84 to the destination system. The Helmert parameters of the +towgs84 option of the PROJ4 chain work both directly and inversely.

The options are then two: tell QGIS which are the preferred datum when reprojecting between those coordinate systems, or create a new system with the desired datum, and calculate coordinates towards that system. I do not know which is the best option for the transform function, but let's see both.


Default Datum

In Settings > Options, add a default datum, select source and destination CRS, select the desired datum and accept.

default-datum

The origin CRS do not have different datum to choose from, you just have to choose between the destination options. The Options-CRS should look like this:

options-crs

You could test if the transform function takes this global indication into account. Or create a new CRS.


Custom CRS

In Settings > Custom Projections, add a new CRS, give it a name and write the string PROJ4 such as the EPSG:3003 but with the desired +towgs84 parameters:

custom-crs

Once added, the new CRS is saved in the database of custom systems and a very high USER number is granted. You can find it among the systems available for your project:

project-properties

Finally, rewrite the expression:

x( transform( $geometry, 'EPSG:32632', 'USER:100047' ) )
  • Thanks a lot for your answer. I have verified that using default datum transformation in Settings> Options don't affect coordinates values obtained from the transformation expression. So I think I can use your second tip. About this I would like to ask: if i had to perform an inverse transformation (epsg: 3003> epsg 32632) with the same expression used I should set as source CRS the custom CRS "MonteMario transformed = 10047" instead of epsg 3003? – Andrew-63 Jan 2 at 17:01
  • Yes it is. As long as you want the function to assume the ETRS89 datum for the EPSG: 3003 coordinate system, use the custom CRS instead. @Andrew-63, please edit your question by clarifying the coordinate systems among which you wish to transform and the datum of your choice. That information has been lost and I would like to edit the answer too. – Gabriel De Luca Jan 2 at 19:43
  • Thanks, i have inserted the epsg codes of source and destination coordinate systems in the expression and the datum transformation epsg code in the question text as You ask. – Andrew-63 Jan 3 at 10:34

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.