gps_data_analyzer.gps_data module¶
-
class
gps_data_analyzer.gps_data.GpsPoints(*args, local_crs: int = None, x_col: str = None, y_col: str = None, z_col: str = None, time_col: str = None, time_sort: bool = True, **kwargs)¶ Bases:
gps_data_analyzer.gps_data._GpsBaseClass to store GPS points with Z coordinates and timestamps.
-
_has_time= True¶
-
_has_z= True¶
-
-
class
gps_data_analyzer.gps_data.PoiPoints(*args, local_crs: int = None, x_col: str = None, y_col: str = None, z_col: str = None, time_col: str = None, time_sort: bool = True, **kwargs)¶ Bases:
gps_data_analyzer.gps_data._GpsBaseClass to store PoI points with only X and Y coordinates.
-
_has_time= False¶
-
_has_z= False¶
-
-
class
gps_data_analyzer.gps_data._GpsBase(*args, local_crs: int = None, x_col: str = None, y_col: str = None, z_col: str = None, time_col: str = None, time_sort: bool = True, **kwargs)¶ Bases:
geopandas.geodataframe.GeoDataFrameClass to wrap a
geopandas.GeoDataFrameand format it in order to store GPS points.-
_default_input_crs¶ The default EPSG code of input data (only used when
input_crsisNone).- Type
-
_default_x_col¶ The default column name of input data that contains X coordinates (only used when
x_colisNone).- Type
-
_default_y_col¶ The default column name of input data that contains Y coordinates (only used when
y_colisNone).- Type
-
_default_z_col¶ The default column name of input data that contains Z coordinates (only used when
z_colisNoneand_has_zisTrue).- Type
-
_default_time_col¶ The default column name of input data that contains timestamps (only used when
time_colisNoneand_has_timeisTrue).- Type
-
_default_dt_col¶ The default column name to store delta times (only used when
_has_timeisTrue).- Type
-
_default_dist_col¶ The default column name to store distances (only used when
_has_timeisTrue).- Type
-
_default_velocity_col¶ The default column name to store velocities (only used when
_has_timeisTrue).- Type
-
_use_haversine¶ Indicate whether the distance computations must use the Haversine formula or not.
- Type
- Parameters
df (
pandas.DataFrame) – The data that will be formatted and stored.input_crs (int) – The EPSG code of the input data.
local_crs (int) – The EPSG code of the local projection to which the data will be transformed.
keep_cols (
listofstr) – The columns that should not be discarded.x_col (str) – The name of the column that contains X coordinates.
y_col (str) – The name of the column that contains Y coordinates.
z_col (str) – The name of the column that contains Z coordinates.
time_col (str) – The name of the column that contains timestamps.
time_sort (bool) – Sort data by ascending time (only used when
_has_timeis True).
-
property
_constructor¶ Used when a manipulation result has the same dimensions as the original.
-
_default_dist_col= 'dist'
-
_default_dt_col= 'dt'
-
_default_input_crs= 4326
-
_default_time_col= 'datetime'
-
_default_velocity_col= 'velocity'
-
_default_x_col= 'x'
-
_default_y_col= 'y'
-
_default_z_col= 'z'
-
classmethod
_format_data(df: pandas.core.frame.DataFrame, x_col: str, y_col: str, z_col: str = None, time_col: str = None, time_sort: bool = True) → None¶ Format a
pandas.DataFrameorgeopandas.GeoDataFrame.- Parameters
df (
pandas.DataFrameorgeopandas.GeoDataFrame) – The object to format.x_col (str) – The name of the column containing X or lon coordinates.
y_col (str) – The name of the column containing Y or lat coordinates.
z_col (str, optional) – The name of the column containing Z coordinates.
time_col (str, optional) – The name of the column containing timestamps.
keep_cols (
listofstr, optional) – The names of the columns that should be kept (all others will be discarded).
- time_sort (bool): Sort data by ascending time (only used when
_has_timeis True).
Note
The column containing timestamps can be either in string format (and should thus follow the format given by
datetime_format) or in a subtype ofnumpy.datetime64.- Returns
The formatted data.
- Return type
geopandas.GeoDataFrame
-
_has_time= False
-
_has_z= True
-
classmethod
_normalize_data(df) → None¶ Conpute time delta between consecutive points (in s).
-
_return_attr(attr) → pandas.core.series.Series¶
-
_use_haversine= True
-
add_attribute(attr: pandas.core.series.Series, name: str = None) → None¶ Add a column to the internal
geopandas.GeoDataFrame.- Parameters
attr (
pandas.Series) – The column to add.name (str, optional) – The name of the new attribute. If not provided, the name of the
pandas.Seriesis used.
Note
The labels of the given
pandas.Seriesmust be the same as the ones of the internalgeopandas.GeoDataFrame.
-
property
base_columns¶
-
copy(deep: bool = False)¶ Return a copy of the current object.
- Parameters
deep (bool) – Make a deep copy, including a copy of the data and the indices. With
deep=Falseneither the indices nor the data are copied.
-
datetime_format= '%Y/%m/%d-%H:%M:%S'
-
drop_from_mask(mask: geopandas.geodataframe.GeoDataFrame) → int¶ Drop points contained in the given mask.
- Parameters
mask (
geopandas.GeoDataFrame) – The mask used to drop internal points.
Note
The mask must be a
_GpsBaseorgeopandas.GeoDataFrameobject.If the mask has a radius column, it will be used and drop all points at a distance smaller than the radius values.
- Returns
The number of dropped points.
- Return type
-
equals(other: geopandas.geodataframe.GeoDataFrame) → bool¶ Test whether self and other contain the same elements.
- Parameters
other (
geopandas.GeoDataFrame) – The other object to be compared with self.
Note
- The two objects are converted to
geopandas.GeoDataFramethen they are compared using the
equalsmethod.
- Returns
True if all elements are the same in both objects, False otherwise.
- Return type
-
segments() → geopandas.geodataframe.GeoDataFrame¶ Build segments from the consecutive points.
- Returns
A
geopandas.GeoDataFramecontaining the segments.- Return type
geopandas.GeoDataFrame
-
property
t¶ Get timestamps if
_has_timeisTrueor the t column otherwise.- Returns
Timestamps.
- Return type
pandas.Series
-
property
x¶ Get X coordinates from the geometry.
- Type
pandas.Series
-
property
xy¶ Array with a (x,y) couple of each point.
- Type
numpy.array
-
property
y¶ Get Y coordinates from the geometry.
- Type
pandas.Series
-
-
gps_data_analyzer.gps_data._convert_time(series, format: str = '%Y/%m/%d-%H:%M:%S')¶ Convert a
pandas.Seriescontaining timestamps as strings.- Parameters
series (pandas.Series) – The timestamps given as strings.
format (str, optional) – The format used for conversion.
- Returns
The timestamps converted in
pandas.datetime.- Return type
pandas.Series
-
gps_data_analyzer.gps_data.concatenate(data_sets: list, crs: int = None) → gps_data_analyzer.gps_data.GpsPoints¶ Concatenate several data sets.