mappymatch.constructs.trace#
Classes
|
A Trace is a collection of coordinates that represents a trajectory to be matched. |
- class mappymatch.constructs.trace.Trace(frame)[source]#
A Trace is a collection of coordinates that represents a trajectory to be matched.
- Attributes:
coords: A list of all the coordinates crs: The CRS of the trace index: The index of the trace
- Parameters:
frame (GeoDataFrame)
- property index: Index#
Get index to underlying GeoDataFrame.
- property coords: List[Coordinate]#
Get coordinates as Coordinate objects.
- property crs: CRS#
Get Coordinate Reference System(CRS) to underlying GeoDataFrame.
- classmethod from_geo_dataframe(frame, xy=True)[source]#
Builds a trace from a geopandas dataframe
Expects the dataframe to have geometry column
- Return type:
- Parameters:
frame (GeoDataFrame)
xy (bool)
- Args:
frame: geopandas dataframe with _one_ trace xy: should the trace be projected to epsg 3857?
- Returns:
The trace built from the geopandas dataframe
- classmethod from_dataframe(dataframe, xy=True, lat_column='latitude', lon_column='longitude')[source]#
Builds a trace from a pandas dataframe
Expects the dataframe to have latitude / longitude information in the epsg 4326 format
- Return type:
- Parameters:
dataframe (DataFrame)
xy (bool)
lat_column (str)
lon_column (str)
- Args:
dataframe: pandas dataframe with _one_ trace xy: should the trace be projected to epsg 3857? lat_column: the name of the latitude column lon_column: the name of the longitude column
- Returns:
The trace built from the pandas dataframe
- classmethod from_gpx(file, xy=True)[source]#
Builds a trace from a gpx file.
Expects the file to have simple gpx structure: a sequence of lat, lon pairs
- Return type:
- Parameters:
file (str | Path)
xy (bool)
- Args:
file: the gpx file xy: should the trace be projected to epsg 3857?
- Returns:
The trace built from the gpx file
- classmethod from_csv(file, xy=True, lat_column='latitude', lon_column='longitude')[source]#
Builds a trace from a csv file.
Expects the file to have latitude / longitude information in the epsg 4326 format
- Return type:
- Parameters:
file (str | Path)
xy (bool)
lat_column (str)
lon_column (str)
- Args:
file: the csv file xy: should the trace be projected to epsg 3857? lat_column: the name of the latitude column lon_column: the name of the longitude column
- Returns:
The trace built from the csv file
- classmethod from_parquet(file, xy=True)[source]#
Read a trace from a parquet file
- Args:
file: the parquet file xy: should the trace be projected to epsg 3857?
- Returns:
The trace built from the parquet file
- Parameters:
file (str | Path)
xy (bool)
- classmethod from_geojson(file, index_property=None, xy=True)[source]#
Reads a trace from a geojson file; If index_property is not specified, this will set any property columns as the index.
- Args:
file: the geojson file index_property: the name of the property to use as the index xy: should the trace be projected to epsg 3857?
- Returns:
The trace built from the geojson file
- Parameters:
file (str | Path)
index_property (str | None)
xy (bool)
- downsample(npoints)[source]#
Downsample the trace to a given number of points
- Return type:
- Parameters:
npoints (int)
- Args:
npoints: the number of points to downsample to
- Returns:
The downsampled trace
- drop(index=typing.List)[source]#
Remove points from the trace specified by the index parameter
- Return type:
- Args:
index: the index of the points to drop (0 based index)
- Returns:
The trace with the points removed