PyDecimalDegrees

About

DecimalDegrees is a very simple Python module. It provides functions to convert between degrees/minutes/seconds and decimal degrees. I decided to write it while I was reading Mapping Hacks and trying to rewrite some of Perl scripts presented in this great book to Python. This module was inspired by Walter Mankowski’s Geo::Coordinates::DecimalDegrees module for Perl, originally located in CPAN archives.

Download

pydecimaldegrees-1.0.zip

pydecimaldegrees-1.0.tar.gz

Example

import decimaldegrees as dd

# Input coordinate in DMS format
coord = { "degrees": 121, "minutes": 8, "seconds": 6 }

# Convert coordinate from DMS to DD
d = dd.dms2decimal(coord["degrees"], coord["minutes"], coord["seconds"])
print d

# Convert coordinate DD to DM
dm = dd.decimal2dm(d)
print dm

# Convert coordinate from DD to back to DMS
dms = dd.decimal2dms(d)
print dms

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>