pygplates.LatLonPoint
- class pygplates.LatLonPoint
Bases:
Boost.Python.instance
Represents a point in 2D geographic coordinates (latitude and longitude).
LatLonPoints are not equality (
==
,!=
) comparable (will raiseTypeError
when compared) and are not hashable (cannot be used as a key in adict
).As a convenience the North and South poles are available as class attributes:
pygplates.LatLonPoint.north_pole
pygplates.LatLonPoint.south_pole
- __init__(latitude, longitude)
Create a LatLonPoint instance from a latitude and longitude.
- Parameters
latitude (float) – the latitude (in degrees)
longitude (float) – the longitude (in degrees)
- Raises
InvalidLatLonError if latitude or longitude is invalid
point = pygplates.LatLonPoint(latitude, longitude)
Note
latitude must satisfy
is_valid_latitude()
and longitude must satisfyis_valid_longitude()
, otherwise InvalidLatLonError will be raised.
Methods
__init__
(latitude, longitude)Create a LatLonPoint instance from a latitude and longitude.
Returns the latitude (in degrees).
Returns the longitude (in degrees).
is_valid_latitude
(latitude)[staticmethod] Returns
True
if latitude is in the range [-90, 90].is_valid_longitude
(longitude)[staticmethod] Returns
True
if longitude is in the range [-360, 360].Returns the tuple (latitude,longitude) in degrees.
Returns the cartesian coordinates as a
PointOnSphere
.to_xyz
()Returns the cartesian coordinates as the tuple (x,y,z).
Attributes
north_pole
south_pole
- get_latitude()
Returns the latitude (in degrees).
- Return type
float
- get_longitude()
Returns the longitude (in degrees).
- Return type
float
- static is_valid_latitude(latitude)
[staticmethod] Returns
True
if latitude is in the range [-90, 90].- Parameters
latitude (float) – the latitude (in degrees)
- Return type
bool
if pygplates.LatLonPoint.is_valid_latitude(latitude): ...
- static is_valid_longitude(longitude)
[staticmethod] Returns
True
if longitude is in the range [-360, 360].- Parameters
longitude (float) – the longitude (in degrees)
- Return type
bool
GPlates uses the half-open range (-180.0, 180.0], but accepts [-360.0, 360.0] as input
if pygplates.LatLonPoint.is_valid_longitude(longitude): ...
- to_lat_lon()
Returns the tuple (latitude,longitude) in degrees.
- Return type
the tuple (float,float)
latitude, longitude = lat_lon_point.to_lat_lon()
- to_point_on_sphere()
Returns the cartesian coordinates as a
PointOnSphere
.- Return type
- to_xyz()
Returns the cartesian coordinates as the tuple (x,y,z).
- Return type
the tuple (float,float,float)
x, y, z = lat_lon_point.to_xyz()
This is similar to
PointOnSphere.to_xyz()
.