Module points
Handle 2-d NumPy, tuples or other arrays as LatLons or as
pseudo-x/-y pairs.
NumPy arrays are assumed to contain rows of points with a lat-, a
longitude -and possibly other- values in different columns. While
iterating over the array rows, create an instance of a given
LatLon class "on-the-fly" for each row with the row's
lat- and longitude.
The original NumPy array is read-accessed only and never duplicated,
except to create a subset of the original array.
For example, to process a NumPy array, wrap the array by instantiating
class Numpy2LatLon and specifying the column index for the
lat- and longitude in each row. Then, pass the Numpy2LatLon instance to any pygeodesy function or
method accepting a points argument.
Similarly, class Tuple2LatLon is used to instantiate a LatLon for
each 2+tuple in a list, tuple or sequence of such 2+tuples from the index
for the lat- and longitude index in each 2+tuple.
Tested with 64-bit Python 2.6.9 (and numpy 1.6.2), 2.7.13 and 2.7.14
(both with numpy 1.13.1), 3.5.3 and 3.6.3 on macOS 10.12.6 Sierra, with
64-bit Intel-Python 3.5.3 (and numpy 1.11.3) on macOS 10.12.6 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 11.0.3.
|
bounds(points,
radius=None,
wrap=True,
LatLon=None)
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 an array, list,
sequence, set or tuple of LatLon points. |
|
|
|
isconvex(points,
radius=None,
wrap=True)
Determine whether a polygon defined by an array, list, sequence, set
or tuple of LatLon points is convex. |
|
|
bounds(points,
radius=None,
wrap=True,
LatLon=None)
|
|
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).
LatLon - Optional class to use (LatLon).
- Returns:
- 4-Tuple (lolat, lolon, hilat, hilon) corners (degrees) or 2-tuple
(loLatLon, hiLatLon) if (LatLon) given.
- 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 an array, 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 an array, 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:
CrossError - Colinear point.
TypeError - Some points are not LatLon.
ValueError - Too few points.
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)
|