To visualize trajectories within a specific geographic area, use nusc_map.render_map_patch to create a background map and then overlay trajectories using plot_vehicle_nice or plot_vehicle_mm.
Steps:
- Define a Region of Interest (ROI) using
x_min, y_min, x_max, and y_max. - Specify the map
layers to render (e.g., 'drivable_area', 'lane', 'ped_crossing'). - Render the patch using
nusc_map.render_map_patch. - Use
plot_vehicle_nice (for standard samples) or plot_vehicle_mm (for mode-specific samples) to draw on the axes.
# 1. Define ROI and layers
x_min, x_max, y_min, y_max = 773.0, 1100.0, 1231.0, 1510.0
layers = ['drivable_area', 'road_segment', 'lane', 'ped_crossing', 'walkway', 'stop_line', 'road_divider', 'lane_divider']
# 2. Render map patch
my_patch = (x_min, y_min, x_max, y_max)
fig, ax = nusc_map.render_map_patch(my_patch, layers, figsize=(10, 10), alpha=0.1, render_egoposes_range=False)
# 3. Plot trajectories
plot_vehicle_nice(ax, predictions, scene.dt, max_hl=10, ph=ph, map=None, x_min=x_min, y_min=y_min)
plot_vehicle_mm(ax, predictions_mm, scene.dt, max_hl=10, ph=ph, map=None, x_min=x_min, y_min=y_min)