Utils
Helper functions and classes.
Modules
For readability, the full path is listed below and not used in other parts of the documentation.
mappymatch.utils.exceptions
mappymatch.utils.geo
mappymatch.utils.plot
mappymatch.utils.trace
mappymatch.utils.url
exceptions module
geo module
- coord_to_coord_dist(a: mappymatch.constructs.coordinate.Coordinate, b: mappymatch.constructs.coordinate.Coordinate) float [source]
Compute the distance between two coordinates.
- Parameters
a – The first coordinate
b – The second coordinate
- Returns
The distance in meters
plot module
- plot_geofence(geofence: mappymatch.constructs.geofence.Geofence, m: Optional[folium.folium.Map] = None)[source]
Plot geofence.
- Parameters
geofence – The geofence to plot
m – the folium map to plot on
- Returns
The updated folium map with the geofence.
- plot_map(tmap: mappymatch.maps.nx.nx_map.NxMap, m: Optional[folium.folium.Map] = None)[source]
Plot the roads on an NxMap.
- Parameters
tmap – The Nxmap to plot.
m – the folium map to add to
- Returns
The folium map with the roads plotted.
- plot_match_distances(matches: mappymatch.matchers.match_result.MatchResult)[source]
Plot the points deviance from known roads with matplotlib.
- Parameters
matches (MatchResult) – The coordinates of guessed points in the area in the form of a MatchResult object.
- plot_matches(matches: typing.Union[mappymatch.matchers.match_result.MatchResult, typing.List[mappymatch.constructs.match.Match]], crs=<Projected CRS: EPSG:3857> Name: WGS 84 / Pseudo-Mercator Axis Info [cartesian]: - X[east]: Easting (metre) - Y[north]: Northing (metre) Area of Use: - name: World between 85.06°S and 85.06°N. - bounds: (-180.0, -85.06, 180.0, 85.06) Coordinate Operation: - name: Popular Visualisation Pseudo-Mercator - method: Popular Visualisation Pseudo Mercator Datum: World Geodetic System 1984 ensemble - Ellipsoid: WGS 84 - Prime Meridian: Greenwich )[source]
Plots a trace and the relevant matches on a folium map.
Args: matches: A list of matches or a MatchResult. crs: what crs to plot in. Defaults to XY_CRS.
- Returns
A folium map with trace and matches plotted.
- plot_path(path: List[mappymatch.constructs.road.Road], crs: pyproj.crs.crs.CRS, m: Optional[folium.folium.Map] = None, line_color='red', line_weight=10, line_opacity=0.8)[source]
Plot a list of roads.
- Parameters
path – The path to plot.
crs – The crs of the path.
m – The folium map to add to.
line_color – The color of the line.
line_weight – The weight of the line.
line_opacity – The opacity of the line.
- plot_trace(trace: mappymatch.constructs.trace.Trace, m: Optional[folium.folium.Map] = None, point_color: str = 'black', line_color: Optional[str] = 'green')[source]
Plot a trace.
- Parameters
trace – The trace.
m – the folium map to plot on
point_color – The color the points will be plotted in.
line_color – The color for lines. If None, no lines will be plotted.
- Returns
An updated folium map with a plot of trace.
trace module
- remove_bad_start_from_trace(trace: mappymatch.constructs.trace.Trace, distance_threshold: float) mappymatch.constructs.trace.Trace [source]
Remove points at the beginning of a trace if it is a gap is too big.
Too big is defined by distance threshold.
- Parameters
trace – The trace.
distance_threshold – The distance threshold.
- Returns
The new trace.