-
-
Save chrisjsimpson/076a82b51e8540a117e8aa5e793d06ec to your computer and use it in GitHub Desktop.
Revisions
-
chrisjsimpson revised this gist
Apr 1, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,7 @@ def dms2dec(dms_str): sign = -1 if re.search('[swSW]', dms_str) else 1 numbers = [*filter(len, re.split('\D+', dms_str, maxsplit=4))] degree = numbers[0] minute = numbers[1] if len(numbers) >= 2 else '0' -
jeteon revised this gist
May 22, 2016 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,10 +35,10 @@ def dms2dec(dms_str): numbers = filter(len, re.split('\D+', dms_str, maxsplit=4)) degree = numbers[0] minute = numbers[1] if len(numbers) >= 2 else '0' second = numbers[2] if len(numbers) >= 3 else '0' frac_seconds = numbers[3] if len(numbers) >= 4 else '0' second += "." + frac_seconds return sign * (int(degree) + float(minute) / 60 + float(second) / 3600) -
jeteon revised this gist
May 22, 2016 . 1 changed file with 9 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,11 +31,14 @@ def dms2dec(dms_str): dms_str = re.sub(r'\s', '', dms_str) sign = -1 if re.search('[swSW]', dms_str) else 1 numbers = filter(len, re.split('\D+', dms_str, maxsplit=4)) degree = numbers[0] minute = numbers[1] if len(numbers) >= 2 else '0' second = numbers[2] if len(numbers) >= 3 else '0' frac_seconds = numbers[3] if len(numbers) >= 4 else '0' second += "." + frac_seconds return sign * (int(degree) + float(minute) / 60 + float(second) / 3600) -
tomwhipple revised this gist
Sep 2, 2012 . 1 changed file with 18 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,33 @@ #!/env/python # coding=utf8 """ Converting Degrees, Minutes, Seconds formatted coordinate strings to decimal. Formula: DEC = (DEG + (MIN * 1/60) + (SEC * 1/60 * 1/60)) Assumes S/W are negative. """ import re def dms2dec(dms_str): """Return decimal representation of DMS >>> dms2dec(utf8(48°53'10.18"N)) 48.8866111111F >>> dms2dec(utf8(2°20'35.09"E)) 2.34330555556F >>> dms2dec(utf8(48°53'10.18"S)) -48.8866111111F >>> dms2dec(utf8(2°20'35.09"W)) -2.34330555556F """ dms_str = re.sub(r'\s', '', dms_str) -
tomwhipple created this gist
Sep 2, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ """ Converting Degrees, Minutes, Seconds formatted coordinate strings to decimal. Formula: DEC = (DEG + (MIN * 1/60) + (SEC * 1/60 * 1/60)) Assumes S/W are negative. """ import re def dms2dec(dms_str): dms_str = re.sub(r'\s', '', dms_str) if re.match('[swSW]', dms_str): sign = -1 else: sign = 1 (degree, minute, second, frac_seconds, junk) = re.split('\D+', dms_str, maxsplit=4) return sign * (int(degree) + float(minute) / 60 + float(second) / 3600 + float(frac_seconds) / 36000)