I have trajectory data, where each trajectory consists of a sequence of coordinates and each trajectory is identified by a unique ID.
These trajectories are in x - y plane, and I want to divide the whole plane into equal sized cell grid (square grid). This grid is obviously invisible but is used to divide trajectories into sub-trajectories. Whenever a trajectory intersects with a grid line, it becomes a new sub-trajectory with "new_id", i.e a trajectory is divided at the intersections of the grid lines, and each of these segments has new unique id.
Finally, I am hoping to pick any random grid cell and retrieve all the sub-trajectories in that cell.
Please suggest me a way to divide the 2d plane into the grid, and how should the trajectories be segmented on encountering grid lines. I am working on Python, and seek some python implementation links, suggestions, algorithms, or even a pseudocode for the same.
Please let me know if anything is unclear.