2

I have incorporated a geometry generator into a style in QGIS 3.4 which creates a callout line from a feature to its relevant spatial position.

For reasons out of my control our projects use CRS: EPSG:27700 but some of the layers we need to import use CRS: EPSG:4326. QGIS handles this fine and can plot the features, but the geometry generator cannot.

I know I could convert beforehand but this is not practical for all our users so I just want the expression to handle this for them.

I am looking for a method to convert from '4326' to '27700' within the expression but I am not currently aware if this is possible.

My current geometry generator expression

make_line(make_point($x, $y), make_point("Longitude", "Latitude"))

The "Longitude" and "Latitude" fields relate to the fields in the relevant layer which is projected with EPSG:4326.

  • 1
    Have you tried something with transform($geomerty, 'EPSG:4326', 'EPSG:27700')? – Taras Jun 28 '19 at 10:02
  • 1
    Have you had a look at the transform-expression? I am not exactly sure, where to place it, though. Based on Taras comment, I'd say make_line(make_point($x,$y),transform(make_point("Longitude",Latitude"),'EPSG:4326','EPSG:27700')). – Erik Jun 28 '19 at 10:02
  • Thank you both - I did not consider this. I have just tried @Erik suggestion but this is still pointing towards the original lat/long position – AWGIS Jun 28 '19 at 10:13
  • Had a play around but cannot get this method to work - I have tried transforming each field independently with no avail. – AWGIS Jun 28 '19 at 10:39
  • 1
    Try adding new fields to the attribute table with transform("Longitude",'EPSG:4326','EPSG:27700') and then using these fields instead of Longitude/Latitude. – Erik Jun 28 '19 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.