Package pygeodesy :: Module points :: Class Numpy2LatLon
[frames] | no frames]

Class Numpy2LatLon

       object --+            
                |            
    _abcoll.Sized --+        
                    |        
       object --+   |        
                |   |        
 _abcoll.Iterable --+        
                    |        
       object --+   |        
                |   |        
_abcoll.Container --+        
                    |        
     _abcoll.Sequence --+    
                        |    
              _Basequence --+
                            |
                           Numpy2LatLon

Wrapper for NumPy arrays as "on-the-fly" LatLon points.

Nested Classes

Inherited from _abcoll.Sized: __metaclass__

Instance Methods
 
__init__(self, array, ilat=0, ilon=1, LatLon=None)
Handle a NumPy array as a sequence of LatLon points.
 
__contains__(self, latlon)
Check for a specific lat-/longitude.
 
__getitem__(self, index)
Return row[index] as LatLon or return a Numpy2LatLon slice.
 
__iter__(self)
Yield rows as LatLon.
 
__len__(self)
Return the number of rows.
 
__repr__(self)
Return a string representation.
 
__reversed__(self)
Yield rows as LatLon in reverse order.
 
__str__(self)
Return a string representation.
integer
count(self, latlon)
Count the number of rows with a specific lat-/longitude.
 
find(self, latlon, *start_end)
Find the first row with a specific lat-/longitude.
 
findall(self, latlon, *start_end)
Yield indices of all rows with a specific lat-/longitude.
integer
index(self, latlon, *start_end)
Find index of the first row with a specific lat-/longitude.
 
point(self, row)
Instantiate a point LatLon.
 
rfind(self, latlon, *start_end)
Find the last row with a specific lat-/longitude.
 
subset(self, indices)
Return a subset of the NumPy array.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__

Class Methods

Inherited from _abcoll.Sized: __subclasshook__

Class Variables
  __abstractmethods__ = frozenset([])
Properties
  epsilon
Get the tolerance for equality tests (float).
  ilat
Get the latitudes column index (integer).
  ilon
Get the longitudes column index (integer).
  isNumpy2
Is this a Numpy2 wrapper?
  shape
Get the shape of the NumPy array (2-tuple).

Inherited from object: __class__

Method Details

__init__(self, array, ilat=0, ilon=1, LatLon=None)
(Constructor)

 

Handle a NumPy array as a sequence of LatLon points.

Parameters:
  • array - NumPy array (numpy.array).
  • ilat - index of the latitudes column (integer).
  • ilon - index of the longitudes column (integer).
  • LatLon - LatLon class to use (internal).
Raises:
  • IndexError - If array.shape is not (1+, 2+).
  • TypeError - If array is not a NumPy array or LatLon is not a class with ilat and ilon attributes.
  • ValueError - If the ilat and/or ilon values are the same or out of range.
Overrides: object.__init__

Example:

>>> type(array)
<type 'numpy.ndarray'>  # <class ...> in Python 3+
>>> points = Numpy2LatLon(array, lat=0, lon=1)
>>> simply = simplifyRDP(points, ...)
>>> type(simply)
<type 'numpy.ndarray'>  # <class ...> in Python 3+
>>> sliced = points[1:-1]
>>> type(sliced)
<class '...Numpy2LatLon'>

__contains__(self, latlon)
(In operator)

 

Check for a specific lat-/longitude.

Parameters:
  • latlon - Point (LatLon) or 2-tuple (lat, lon).
Returns:
True if present, False otherwise.
Raises:
  • TypeError - Invalid latlon.
Overrides: _abcoll.Container.__contains__

__getitem__(self, index)
(Indexing operator)

 

Return row[index] as LatLon or return a Numpy2LatLon slice.

Overrides: _abcoll.Sequence.__getitem__

__iter__(self)

 

Yield rows as LatLon.

Overrides: _abcoll.Iterable.__iter__

__len__(self)
(Length operator)

 

Return the number of rows.

Overrides: _abcoll.Sized.__len__

__repr__(self)
(Representation operator)

 

Return a string representation.

Overrides: object.__repr__

__reversed__(self)

 

Yield rows as LatLon in reverse order.

Overrides: _abcoll.Sequence.__reversed__

__str__(self)
(Informal representation operator)

 

Return a string representation.

Overrides: object.__str__

count(self, latlon)

 

Count the number of rows with a specific lat-/longitude.

Parameters:
  • latlon - Point (LatLon) or 2-tuple (lat, lon)
Returns: integer
Count (integer).
Raises:
  • TypeError - Invalid latlon.
Overrides: _abcoll.Sequence.count

find(self, latlon, *start_end)

 

Find the first row with a specific lat-/longitude.

Parameters:
  • latlon - Point (LatLon) or 2-tuple (lat, lon).
  • start_end - Optional [start [, end]] index (integers).
Returns:
Index or -1 if not found (integer).
Raises:
  • TypeError - Invalid latlon.

findall(self, latlon, *start_end)

 

Yield indices of all rows with a specific lat-/longitude.

Parameters:
  • latlon - Point (LatLon) or 2-tuple (lat, lon).
  • start_end - Optional [start [, end]] index (integers).
Returns:
Indices (iterator).
Raises:
  • TypeError - Invalid latlon.

index(self, latlon, *start_end)

 

Find index of the first row with a specific lat-/longitude.

Parameters:
  • latlon - Point (LatLon) or 2-tuple (lat, lon).
  • start_end - Optional [start [, end]] index (integers).
Returns: integer
Index (integer).
Raises:
  • TypeError - Invalid latlon.
  • ValueError - Point not found.
Overrides: _abcoll.Sequence.index

point(self, row)

 

Instantiate a point LatLon.

Parameters:
  • row - Array row (numpy.array).
Returns:
Point (LatLon).
Overrides: _Basequence.point

rfind(self, latlon, *start_end)

 

Find the last row with a specific lat-/longitude.

Parameters:
  • latlon - Point (LatLon) or 2-tuple (lat, lon).
  • start_end - Optional [start [, end]] index (integers).
Returns:
Index or -1 if not found (integer).
Raises:
  • TypeError - Invalid latlon.

Note: Keyword order, first stop, then start.

subset(self, indices)

 

Return a subset of the NumPy array.

Parameters:
  • indices - Row indices (ints).
Returns:
Sub-array (numpy.array).
Raises:
  • IndexError - Out of range indices value.
  • TypeError - If indices is not a range or a list of ints.

Note: A subset is different from a slice in 2 ways: (a) the subset is typically specified as a list of (un-)ordered indices and (b) the subset allocates a new, separate NumPy array while a slice is just an other view of the original NumPy array.


Property Details

epsilon

Get the tolerance for equality tests (float).

Get Method:
epsilon(self) - Get the tolerance for equality tests (float).
Set Method:
epsilon(self, eps) - Set the tolerance for equality tests.

ilat

Get the latitudes column index (integer).

Get Method:
ilat(self) - Get the latitudes column index (integer).

ilon

Get the longitudes column index (integer).

Get Method:
ilon(self) - Get the longitudes column index (integer).

isNumpy2

Is this a Numpy2 wrapper?

Get Method:
isNumpy2(self) - Is this a Numpy2 wrapper?

shape

Get the shape of the NumPy array (2-tuple).

Get Method:
shape(self) - Get the shape of the NumPy array (2-tuple).