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.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04d189ed27d56bf6156a1d41d969216d3d939c2b8919f8110e20331420619b60 |
|
MD5 | e8658776cc885c38cf72a5662d582324 |
|
BLAKE2b-256 | 728345f6c1bae52d8360241d879eee833b7a1b153f0814d0e5620c4a21599e2f |