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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for latlonconv-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ab0cd1f90611837745921d454cf69937fdf5ad6aee024a0ab52c092f88ba701 |
|
MD5 | 77fda03bc267f810ca828e3bca6dc30d |
|
BLAKE2b-256 | fa6fae30fa46eb4587c2f4f2b4f0df0d7c3cab2e493c5a224d8b02c57cc47941 |