I’ve two columns (Oracle) namely latitude and longitude in format I’ve mentioned below.
Could anyone help me on how to convert them into radians using Oracle/MySQL or Python?
Example: 11.08.10N (Latitude), 084.46.07W (Longitude)
Note:
The latitude of a location is represented by three two-digit numbers separated by periods in the order of degrees,minutes from degrees,seconds from degrees that are followed by a N for north or a S for south.
The longitude of a location is represented by a three digit number and two two-digit numbers separated by periods in the order of degrees,minutes from degrees,seconds from degrees that are followed by a W for west or an E for east
I’ve seen solutions which they directly convert using radians function like below.
lat = radians(latitude_value)
lon = radians(longitude_value)
This doesn’t help me in my scenario.
2
Answers
It’s just basic string manipulation and math. In mysql, for latitude:
Similarly, for longitude:
fiddle
In Oracle, you can use:
Which, for the sample data:
Outputs:
fiddle