Crosswalk Analyzer¶
Edge Classifier¶
- night_light.analyzer.edge_classifier.classify_edges_by_intersection(con: DuckDBPyConnection)¶
Classify edges based on intersection with street segments and oneway status.
- Parameters:
con (
DuckDBPyConnection
)
- night_light.analyzer.edge_classifier.decompose_crosswalk_edges(con: DuckDBPyConnection)¶
Decompose crosswalks polygons into separate edges.
- Parameters:
con (
DuckDBPyConnection
)
- night_light.analyzer.edge_classifier.simplify_crosswalk_polygon_to_box(con: DuckDBPyConnection)¶
Converts each crosswalk polygon into its minimum bounding rectangle (oriented).
- Parameters:
con (
DuckDBPyConnection
)
Crosswalk Center¶
- night_light.analyzer.crosswalk_center.find_crosswalk_centers(con: DuckDBPyConnection)¶
Find the centers of crosswalks.
- Parameters:
con (
DuckDBPyConnection
)
Vehicle Direction¶
- night_light.analyzer.vehicle_direction.identify_vehicle_direction(con: DuckDBPyConnection)¶
Identify the direction of the vehicle for each side of the road segment.
One-way streets:
Find the intersecting street segment to the crosswalk.
Compute relative distance between the first point of the street segment and the two points of the pedestrian edge. The closer of the two points to the street segment’s first point is the “from_coord” and the other is the “to_coord.” This is predefined by the street segments dataset since all the one ways were marked as
FT
.
Two-way streets:
Case 1: If the crosswalk center’s X value is greater than the street center point’s X value, we assume the vehicle is moving from “y_smaller” to “y_larger.”
For the from_coord, choose the vertex of the pedestrian edge with the smaller Y.
For the to_coord, choose the vertex with the larger Y.
Case 2: If the crosswalk center’s X is less than the street center point’s X value, we assume the reverse.
For from_coord, choose the vertex with the larger Y.
For to_coord, choose the vertex with the smaller Y.
Case 3: If the crosswalk center’s Y is greater than the street center point’s Y value, we assume the vehicle is moving from “x_larger” to “x_smaller.”
For from_coord, choose the vertex with the larger X.
For to_coord, choose the vertex with the smaller X.
Case 4: If the crosswalk center’s Y is less than the street center point’s Y value, then we assume the reverse.
For from_coord, choose the vertex with the smaller X.
For to_coord, choose the vertex with the larger X.
- Parameters:
con (
DuckDBPyConnection
)
Distance Analysis¶
- night_light.analyzer.distance.create_crosswalk_centers_lights(con: DuckDBPyConnection)¶
Create a table called crosswalk_centers_lights.
This table will include the columns streetlight_id and streetlight_dist. - streetlight_id: a list of ints - streetlight_dist: a list of floats :type con:
DuckDBPyConnection
:param con: connection to duckdb table.
- night_light.analyzer.distance.find_streetlights_crosswalk_centers(con: DuckDBPyConnection, dist: float)¶
Find all of the streetlights within a distance from each crosswalk center.
Fill in the columns: - streetlight_id: a list of streetlight IDs (ints) within the specified distance from each crosswalk centerpoint - streetlight_dist: a list of distances (in meters) from the centerpoint to each nearby streetlight.
- Parameters:
con (
DuckDBPyConnection
) – connection to duckdb tabledist (
float
) – float of meters to search for streetlights near each crosswalk centerpoint
- night_light.analyzer.distance.long_lat_flipper(con: DuckDBPyConnection, table: str)¶
Flips the coordinate so that they are in lat, long order instead of long, lat
- Parameters:
Name (string)
con (
DuckDBPyConnection
)table (
str
)
- night_light.analyzer.distance.meters_to_degrees(meters: float, latitude=42.3601)¶
Convert meters to degrees
Rough calculation that defults the location to boston. Calculation will tend to be an overestimates. It will pick which ever degree value is bigger between lat and long.
- Parameters:
meters (
float
) – intlatitude – int (defaults to boston)
- Returns:
int in degrees
Contrast Analysis¶
- night_light.analyzer.contrast.add_streetlight_distances(con: DuckDBPyConnection)¶
Append distances of the streetlights to the table.
- Parameters:
con (
DuckDBPyConnection
)
- night_light.analyzer.contrast.calculate_contrast_heuristics(con: DuckDBPyConnection, threshold: float)¶
Computes to_heuristic, from_heuristic, and contrast_heuristic for crosswalk centers.
Uses a threshold to determine when contrast should be classified as ‘no contrast’. Hueristic is calculated based on distance and angle of streetlights.
- Parameters:
con (
DuckDBPyConnection
)threshold (
float
)
- night_light.analyzer.contrast.classify_lights_by_side(con: DuckDBPyConnection)¶
Classify lights as either to or from side of the crosswalk center.
The algorithm compares the sign of the cross products to classify. Refer to the script for detailed steps.
- Parameters:
con (
DuckDBPyConnection
)
Brightness Analysis¶
- night_light.analyzer.brightness.calculate_percieved_brightness(conn)¶
Calculate percieved brightness by adding A + B hueristic together.