Skip to main content

Methods for representing geographic coordinates

Project description

latlonconv

A copy of the LatLon package that actually works (and does not depend on pyproj), but has reduced functionality focusing on format conversion only:

Example

import latlonconv as ll

coord1 = ll.LatLon(32.30642, 122.61458)
coord2 = ll.string2latlon("""32.30642° N""", """122.61458° W""", """D%° %H""")
conv1 = coord1.to_string("""d%° %m%' %S%" %H""")
conv2 = coord2.to_string("""d%° %m%' %S%" %H""")

print(conv1)
print(conv2)

Format string syntax

latlonconv.string2latlon and latlonconv.LatLon.to_string both take a formatter string which is loosely modeled on the format keyword used in datetime’s strftime function. Indicator characters (e.g. H or D) are placed between a specific separator character (%) to specify the way in which a coordinate string is formatted. Possible values are as follows:

H is a hemisphere identifier (e.g. N, S, E or W)

D is a coordinate in decimal degrees notation (e.g. 5.833)

d is a coordinate in degrees notation (e.g. 5)

M is a coordinate in decimal minutes notation (e.g. 54.35)

m is a coordinate in minutes notation (e.g. 54)

S is a coordinate in seconds notation (e.g. 28.93)

Any other characters (e.g. ‘ ‘ or ‘, ‘) will be treated as a separator between the above components.

All components should be separated by the % character. For example, if the coord_str is ‘5, 52, 59.88_N’, the format_str would be ‘d%, %m%, %S%_%H’

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

latlonconv-1.0.0.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

latlonconv-1.0.0-py3-none-any.whl (18.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page