0

I'm not familiar with coding.

In QGIS, I would like field attribute to auto populate X and Y value and combine in one field just like highlighted below,

I know that if auto calculate value in field attribute by using $x_at(0) for start X coordinate and $y_at(0) for start Y coordinate,

How to calculate if one field read combination 'Y'N OR 'X'E just like highlighted below?

enter image description here


Has try out this expression $y_at(0) || $x_at(0) but turn like below, still not sure how to space between two value with N and E back at each value.

enter image description here

1

I now have the answer from Display coordinates of points in DMS format in print composer

and already manipulate base on my situation

(CASE WHEN $y_at(0) < 0 THEN '-' ELSE '' END) || floor (abs($y_at(0))) || '°' || floor(((abs($y_at(0))) - floor (abs($y_at(0)))) * 60) ||'\'' || substr( (tostring((((abs($y_at(0))) - floor (abs($y_at(0)))) * 60) - floor(((abs($y_at(0))) - floor (abs($y_at(0)))) * 60)) * 60),1,5) || '" N'|| '\n' || (CASE WHEN $x_at(0) < 0 THEN '-' ELSE '' END) || floor (abs($x_at(0))) || '°' || floor(((abs($x_at(0))) - floor (abs($x_at(0)))) * 60) ||'\'' || substr( (tostring((((abs($x_at(0))) - floor (abs($x_at(0)))) * 60) - floor(((abs($x_at(0))) - floor (abs($x_at(0)))) * 60)) * 60),1,5) || '" E'

enter image description here

It works!

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.