Positions¶
positions ¶
Positions ¶
Positions(
xyz: Union[ndarray, list],
epsg: int = 0,
local_transformer: Transformer = None,
init_local_transformer: bool = True,
epsg_local_cart: int = 4936,
epsg_local_geod: int = 4937,
)
Class representing (georeferenced) positions.
The Positions class can hold one or multiple 3d positions with a corresponding EPSG code for datum information. When creating a Positions instance, a transformation pipeline is created based on the passed points, which can transform the points into a local system tangent to the ellipsoid (grs80). Such a local datum is represented within this class with an EPSG code of 0 and is mainly suitable for local calculations within the Positions.
All transformations, including the local transformation, are carried out using pyproj, a python toolbox for projections and transformations.
Initialize Positions and create local transformer.
If a Positions instance is initialized directly with an EPSG code of 0, such a local transformer cannot be constructed, and a transformation into other EPSG codes is therefore not possible. Use this setting if you don't have any information about the geodetic datum of the passed points. However, if the local transformer is already known, it can be provided during the initialization of the Positions object using the local_transformer variable.
Parameters:
-
xyz(ndarray | list) –1- / 2- dimensional numpy array containing the coordinates of the input positions.
-
epsg(int, default:0) –EPSG code of the datum of the input positions. Defaults to 0.
-
local_transformer(Transformer, default:None) –pyproj transformer that describes the transformation to a local coordinate system. Defaults to None.
-
init_local_transformer(bool, default:True) –Specifies if a local transformer should be initialized. Defaults to True.
-
epsg_local_cart(int, default:4936) –EPSG code of the earth-centered datum that is used to construct the local transformation pipeline. In a first step, the coordinates are transformed to this coordinate frame. In this coordinate frame they are reduced by their mean position. Defaults to 4936.
-
epsg_local_geod(int, default:4937) –In the final step of the local transformation pipeline, the positions reduced by their mean are rotated into a local system tangent to the ellipsoid. The ellipsoid is defined by this parameter using an EPSG code. Both EPSG codes, epsg_local_cart and epsg_local_geod should refer to the same datum (here ETRS89). Defaults to 4937.
Raises:
-
PointSetError–Gets raised if input xyz is not a numpy array.
Source code in trajectopy\core\positions.py
xyz
property
writable
¶
Returns the points within the Positions object.
Returns:
-
ndarray–np.ndarray: 2-dimensional numpy array.
x
property
writable
¶
Returns x coordinate(s).
The x/y/z properties will either return a one-dimensional numpy array or a single float / int depending on whether there is more than one point in the Positions object.
Returns:
-
Union[int, float, ndarray]–Union[int, float, np.ndarray]: X coordinate(s).
y
property
writable
¶
Returns y coordinate(s).
The x/y/z properties will either return a one-dimensional numpy array or a single float / int depending on whether there is more than one point in the Positions object.
Returns:
-
Union[int, float, ndarray]–Union[int, float, np.ndarray]: Y coordinate(s).
z
property
writable
¶
Returns z coordinate(s).
The x/y/z properties will either return a one-dimensional numpy array or a single float / int depending on whether there is more than one point in the Positions object.
Returns:
-
Union[int, float, ndarray]–Union[int, float, np.ndarray]: Z coordinate(s).
crs
property
¶
Returns the Coordinate Reference System.
Returns:
-
CRS(CRS) –pyproj CRS object that represents the current coordinate system.
__len__ ¶
__get_column ¶
Internal method to extract a column from xyz
This method will return one column specified by idx from the xyz array. It distinguishes between the number of points and returns either a single float or a 1-d numpy array.
Parameters:
-
idx(int) –index of the desired column
Returns:
-
Union[int, float, ndarray]–Union[int, float, np.ndarray]: Value / array of that column
Source code in trajectopy\core\positions.py
__set_column ¶
Internal method to change a column of xyz
This method will set a column of xyz to v.
Parameters:
-
v(Union[int, float, ndarray]) –Value(s) with which the column is to be filled. Either a single value or an array of exactly the same length as xyz.
-
idx(int) –column index in xyz
Source code in trajectopy\core\positions.py
to_epsg ¶
to_epsg(
target_epsg: int, inplace: bool = True
) -> Positions
Performs a coordinate transformation using a target CRS.
This method will construct the required pyproj transformer and applies it in order to transform the positions to the target EPSG code.
Parameters:
-
target_epsg(int) –EPSG code of target CRS.
-
inplace(bool, default:True) –Perform transformation in place. Defaults to True.
Raises:
-
PointSetError–Gets raised if it is not possible to recover from a local datum since local transformer is unknown.
Returns:
-
Positions(Positions) –Transformed positions.
Source code in trajectopy\core\positions.py
to_local ¶
to_local(inplace: bool = True) -> Positions
Transform positions to a local frame tangential to the (grs80) ellipsoid.
This is equivalent to a transformation to an EPSG of 0.
Parameters:
-
inplace(bool, default:True) –Perform transformation in place. Defaults to True.
Returns:
-
Positions(Positions) –2-dimensional object containing xyz of the transformed points.
Source code in trajectopy\core\positions.py
mean ¶
mean(inplace: bool = False) -> Positions
Computes the mean of all points within the Positions object.
Parameters:
-
inplace(bool, default:False) –If true, the positions object gets replaced by a single mean position. Defaults to False.
Returns:
-
Positions(Positions) –Contains the mean position.
Source code in trajectopy\core\positions.py
round_to ¶
round_to(prec: float) -> Positions
Rounds all points to a given precision.
Parameters:
-
prec(float) –Desired rounding precision.
Returns:
-
Positions(Positions) –Contains the rounded positions.
Source code in trajectopy\core\positions.py
__add__ ¶
__sub__ ¶
__key ¶
Key generation used for hash generation.
Returns:
-
tuple(tuple) –Key tuple for hashing.
Source code in trajectopy\core\positions.py
__eq__ ¶
__eq__(other: Positions) -> bool
Equality comparison.
Parameters:
-
other(Positions) –Object to compare with.
Returns:
-
bool(bool) –True if equal, False otherwise.
Raises:
-
NotImplementedError–If comparing with incompatible type.