cuSpatial API Reference

Trajectory

trajectory.subset_trajectory_id(trajectory_ids, in_x, in_y, point_ids, timestamps)

Deprecated

trajectory.spatial_bounds(x_coords, y_coords, trajectory_size, trajectory_end_position)

Compute the bounding boxes of sets of trajectories.

Parameters
{params}

Examples

>>> result = trajectory.spatial_bounds(
>>>    cudf.Series([0, 2, 1, 3, 2]),
>>>    cudf.Series([0, 2, 1, 3, 2]),
>>>    cudf.Series([2, 3]),
>>>    cudf.Series([2, 5])
>>> )
>>> print(result)
    x1   y1   x2   y2
0  0.0  0.0  2.0  2.0
1  1.0  1.0  3.0  3.0
trajectory.derive(x_coords, y_coords, object_ids, timestamps)

Derive trajectories from points, timestamps, and ids.

Parameters
{params}
Returns
result_tupletuple (number of discovered trajectories,DataFrame)
DataFrameid, length, and positions of trajectories

for feeding into compute_distance_and_speed

Examples

>>> num_trajectories, result = trajectory.derive(
>>>    cudf.Series([0, 1, 2, 3]),
>>>    cudf.Series([0, 0, 1, 1]),
>>>    cudf.Series([0, 0, 1, 1]),
>>>    cudf.Series([0, 10, 0, 10]))
>>> print(num_trajectories)
    2
>>> print(result)
       trajectory_id  length  position
    0              0       2         2
    1              1       2         4
trajectory.distance_and_speed(x_coords, y_coords, timestamps, length, position)

Compute the distance travelled and speed of sets of trajectories

Parameters
{params}
Returns
resultDataFrame

meters - travelled distance of trajectory speed - speed in m/sec of trajectory

Examples

Compute the distance and speed of the above derived trajectories >>> result = trajectory.distance_and_speed(x, y, timestamps,

result[‘length’], result[‘position’])

>>> print(result)
                   meters          speed
    trajectory_id
    0              1000.0  100000.000000
    1              1000.0  111111.109375

GIS

gis.directed_hausdorff_distance(x, y, count)

Compute the directed Hausdorff distances between all pairs of trajectories.

params x: x coordinates y: y coordinates count: size of each trajectory

Parameters
{params}
Returns
DataFrame: The pairwise directed distance matrix with one row and one
column per input trajectory; the value at row i, column j represents the
hausdorff distance from trajectory i to trajectory j.
gis.haversine_distance(p1_lon, p1_lat, p2_lon, p2_lat)

Compute the haversine distances between an arbitrary list of lon/lat pairs

params p1_lon: longitude of first set of coords p1_lat: latitude of first set of coords p2_lon: longitude of second set of coords p2_lat: latitude of second set of coords

Parameters
{params}
returns
Series: distance between all pairs of lat/lon coords
gis.lonlat_to_xy_km_coordinates(camera_lon, camera_lat, lon_coords, lat_coords)

Convert lonlat coordinates to km x,y coordinates based on some camera origin.

params camera_lon: float64 - longitude camera camera_lat: float64 - latitude camera lon_coords: Series of longitude coords to convert to x lat_coords: Series of latitude coords to convert to y

Parameters
{params}
returns
DataFrame: ‘x’, ‘y’ columns for new km positions of coords
gis.window_points(left, bottom, right, top, x, y)

Return only the subset of coordinates that fall within the numerically closed borders [,] of the defined bounding box.

params left: x coordinate of window left boundary bottom: y coordinate of window bottom boundary right: x coordinate of window right boundary top: y coordinate of window top boundary x: Series of x coordinates that may fall within the window y: Series of y coordinates that may fall within the window

Parameters
{params}
Returns
DataFrame: subset of x, y pairs above that fall within the window