Module points
Handle 2-d NumPy or other arrays as LatLons, psuedo-x, -ys.
NumPy arrays are assumed to contain rows of points with a lat-, a
longitude -and possibly other- values in different columns. Iterating
over the array rows, creates an instance of a given LatLon class
"on-the-fly" for each row with the row's lat- and longitude.
The array is read-accessed only and never duplicated, except to create a
subset.
For example, to process a NumPy array, wrap the array by instantiating
class Numpy2LatLon and specifying the index for the lat- and
longitude column in each row. Then, pass the Numpy2LatLon instance to any pygeodesy function or
method as the points argument.
Tested with 64-bit Python 2.6.9 (and numpy 1.6.2), 2.7.13 (and numpy
1.13.1), 3.5.3 and 3.6.2 on macOS 10.12.6 Sierra, with 64-bit
Intel-Python 3.5.3 (and numpy 1.11.3) on macOS 10.12.5 Sierra and with
Pythonista 3.1 using 64-bit Python 2.7.12 and 3.5.1 (both with numpy
1.8.0) on iOS 10.3.3.
|
LatLon2psxy
Wrapper for LatLon points to pseudo-x- and -y-coordinates.
|
|
Numpy2LatLon
Wrapper for NumPy arrays as "on-the-fly" LatLon
points.
|
|
bounds(points,
radius=None,
wrap=True)
Determine the lower-left and upper-right corners of a polygon defined
by a list, sequence, set or tuple of LatLon points. |
|
|
|
isclockwise(points,
radius=None,
wrap=True)
Determine the direction of a polygon defined by a list, sequence, set
or tuple of LatLon points. |
|
|
|
isconvex(points,
radius=None,
wrap=True)
Determine whether a polygon defined by a list, sequence, set or tuple
of LatLon points is convex. |
|
|
bounds(points,
radius=None,
wrap=True)
|
|
Determine the lower-left and upper-right corners of a polygon defined
by a list, sequence, set or tuple of LatLon points.
- Parameters:
points - The points defining the polygon (LatLon[]).
radius - Optional, mean earth radius (meter).
wrap - Optionally, wrap90(lat) and wrap180(lon) (bool).
- Returns:
- 4-Tuple (lolat, lolon, hilat, hilon) corners (degrees).
- Raises:
TypeError - Some points are not LatLon.
ValueError - Too few points.
Example:
>>> b = LatLon(45,1), LatLon(45,2), LatLon(46,2), LatLon(46,1)
>>> bounds(b)
>>> 45.0, 1.0, 46.0, 2.0
|
isclockwise(points,
radius=None,
wrap=True)
|
|
Determine the direction of a polygon defined by a list, sequence, set
or tuple of LatLon points.
- Parameters:
points - The points defining the polygon (LatLon[]).
radius - Optional, mean earth radius (meter).
wrap - Optionally, wrap90(lat) and wrap180(lon) (bool).
- Returns:
- True if clockwise, False otherwise.
- Raises:
TypeError - Some points are not LatLon.
ValueError - Too few points or zero area polygon.
Example:
>>> f = LatLon(45,1), LatLon(45,2), LatLon(46,2), LatLon(46,1)
>>> isclockwise(f)
>>> t = LatLon(45,1), LatLon(46,1), LatLon(46,2)
>>> isclockwise(t)
|
isconvex(points,
radius=None,
wrap=True)
|
|
Determine whether a polygon defined by a list, sequence, set or tuple
of LatLon points is convex.
- Parameters:
points - The points defining the polygon (LatLon[]).
radius - Optional, mean earth radius (meter).
wrap - Optionally, wrap90(lat) and wrap180(lon) (bool).
- Returns:
- True if convex, False otherwise.
- Raises:
TypeError - Some points are not LatLon.
ValueError - Too few points or a colinear point.
Example:
>>> t = LatLon(45,1), LatLon(46,1), LatLon(46,2)
>>> isconvex(t)
>>> f = LatLon(45,1), LatLon(46,2), LatLon(45,2), LatLon(46,1)
>>> isconvex(f)
|