[GIS] SQL Syntax to extract (convert) Strings with Degrees Minutes to Decimal Degrees

postgispostgresqlsql

I have a PostgreSQL/PostGIS database with a two string fields containing Lat and Long coordinates in degrees and decimal minutes, like this 45° 24.5' N 3° 43.01' E.

How can I convert them into decimal degrees, for use in ST_GeographyFromText?

Best Answer

You may try this:

DMS2DD for PostGIS


EDIT

Presuming this is your PostGIS table,

enter image description here

running the DMS2DD function gives this:

enter image description here


EDIT 2

Because you have only Degrees and Minutes,

enter image description here

in the DMS2DD function you need to comment one single line to achieve your results:

enter image description here