in Education by
I receive the latitude and longitude from GPS with this format: Latitude : 78°55'44.29458"N I need convert this data to: latitude: 78.9288888889 I found this code here: link import re def dms2dd(degrees, minutes, seconds, direction): dd = float(degrees) + float(minutes)/60 + float(seconds)/(60*60); if direction == 'E' or direction == 'S': dd *= -1 return dd; def dd2dms(deg): d = int(deg) md = abs(deg - d) * 60 m = int(md) sd = (md - m) * 60 return [d, m, sd] def parse_dms(dms): parts = re.split('[^\d\w]+', dms) lat = dms2dd(parts[0], parts[1], parts[2], parts[3]) return (lat) dd = parse_dms("78°55'44.33324"N ) print(dd) It is working for for this format dd = parse_dms("78°55'44.33324'N" ) but it is not working for my datafromat. Can anyone help me to solve this problem? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Here's my one liner (fine, fine – maybe it's two lines) :) import re lat = '''51°36'9.18"N''' deg, minutes, seconds, direction = re.split('[°\'"]', lat) (float(deg) + float(minutes)/60 + float(seconds)/(60*60)) * (-1 if direction in ['W', 'S'] else 1) This outputs 51.60255

Related questions

0 votes
    I am trying to write a program that reads data from hundreds of YAML files repetitively and stores certain ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I have a file that looks like this: NODE=SC-1,CPU=90 NODE=SC-1,MEM=10 NODE=SC-1,FS=80 ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have a file that looks like this: NODE=SC-1,CPU=90 NODE=SC-1,MEM=10 NODE=SC-1,FS=80 ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I want to get all the values from a section using config parser I used this but it gives only the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    The different variant of Date() constructor to create date object is/are ___________ i. new Date(date) ii ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    I need to encode a signed integer as hexadecimal using via the two's complement notation. For example I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    each circular outward direction. Suggest her wh F.Soleil 1. Convert (655) in binary number: 2. Convert (487) ... 3. Compute 10001-1111 Select the correct answer from above options...
asked Dec 28, 2021 in Education by JackTerrance
0 votes
    A convert the following Decimal numbers into Binary numbers: a. 68 b. 987 c. 657 I want step by step solutions… Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    Convert the following decimal numbers into binary numbers. a) (58)10 Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    Write a program to convert a decimal number into binary number using function Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    2. Convert the following binary numbers into decimal: (1101) Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    Convert the following decimal numbers into binary: (72)10 Select the correct answer from above options...
asked Dec 11, 2021 in Education by JackTerrance
0 votes
    convert these decimal number into binary no. 1) 987 2) 987 Select the correct answer from above options...
asked Dec 9, 2021 in Education by JackTerrance
0 votes
    convert these decimal number into binary no. 1) 987 2) 987 Select the correct answer from above options...
asked Dec 3, 2021 in Education by JackTerrance
0 votes
    Convert the following decimal number to their binary equivalent 52.0625 Select the correct answer from above options...
asked Dec 2, 2021 in Education by JackTerrance
...