1

I'm a beginner in the use of QGIS and I have a problem with a coordinate conversion for creating a map in QGIS. I have some coordinates that have been collected with GPS in the field in this way: coordinates that should be a degree minutes format (18° 59.072' S, 48° 27.776' E).

I would like to convert them in degree, minutes and seconds or UTM format in an automatic way, to have all the data standardized and create a map in QGIS.

Is there any tool or plugin I can use to do this?

2
  • 2
    Once you used e.g. Excel to bring your data into a format QGIS can interpret as DM, you can use to_decimal() in the field calculator.
    – Erik
    Jan 17 at 9:11
  • Or using QGIS expressions to directly format your input values and convert them to DMS. For the correct expression to do so, you should post a sample of your coordinates as text, not as screenshot.
    – Babel
    Jan 17 at 9:18

1 Answer 1

3

You have a DM format and want to convert it to DMS. Your screenshot shows that the input coordinates consist of digits with two points, separating as well degrees from minutes and acting as decimal separator for minutes, in some cases also containing a letter like E: 18.59.072 and E048.27.776.

  1. Use regexp_replace() to convert the textstring input to a format that can be interpreted correctly as coordinate input for to_decimal() function argument. This format looks like '6°21\'16.445', so you have to replace the first point with ° followed by a space: 18° 59.072' and E048° 27.776'

  2. Convert this to decimal format with to_decimal(): 18.984533333333335 and 48.46293333333333

  3. Convert to dms with to_dms() to get: 18°59′4.3″ and 48°27′46.6″. See the linked help for how you can change the output format.

So all together, it looks like this. In line 4, replace the coordinates textstring with the name of the field that contains the x-coordinates value. For the y-coordinate, replace x with y on line 9:

to_dms(
    to_decimal(
        regexp_replace(
            '18.59.072',  -- your input coordinates or fieldname
            '(.)(\\.)(.*)',
            '\\1° \\3'''
        )
    ),
    'x', -- replace with y for y coordinates
    1
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.