Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pyhton dms to decimal

def conversion(old):
    direction = {'N':1, 'S':-1, 'E': 1, 'W':-1}
    new = old.replace(u'°',' ').replace(''',' ').replace('"',' ')
    new = new.split()
    new_dir = new.pop()
    new.extend([0,0,0])
    return abs((int(new[0])+int(new[1])/60.0+int(new[2])/3600.0) * direction[new_dir])

lat, lon = u'''0°25'30"S, 91°7'W'''.split(', ')
print(conversion(lat), conversion(lon))
Comment

PREVIOUS NEXT
Code Example
Python :: pairwise combinations groupby 
Python :: python create valid filename from string 
Python :: image completion inpainting with python 
Python :: 1 12 123 python 
Python :: simple keras model with one layer 
Python :: use rectangular signal in python 
Python :: get processor model in python 
Python :: how to get maximum value of number in python 
Python :: quote_from_bytes() expected bytes 
Python :: how to get ping from computer IN PYTHON 
Python :: Target Can Be Sum Of List Elements? 
Python :: Connect to MySQL Using Connector Python C Extension 
Python :: blender python get current filename 
Python :: convert numpy array to tfrecord and back 
Python :: how to install qrcode module in python 
Python :: how to skip error python 
Python :: inverse box-cox transformation python 
Python :: How to find the most similar word in a list in python 
Python :: HOW TO CREATE A DATETIME LIST QUICK 
Python :: position text in a box matplotlib 
Python :: To convert Date dtypes from Object to ns,UTC with Pandas 
Python :: python add column to a matrix 
Python :: how to check for updates from github in python 
Python :: handlebars python 
Python :: python 3 docs 
Python :: Flask / Python. Get mimetype from uploaded file 
Python :: how to stop python for some time in python 
Python :: python serial COM3 
Python :: Python RegEx Compile – re.compile() 
Python :: quotation marks n string 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =