I wish I had code to share but I simply don't know where to even start. I have a 1km square grid and what I want to do find the total length of a line segment within that cell and multiply it by the lines speed variable to get a value to populate into a column in the grid dataset. Using the example below Grid 1 should be equal (0.54x5)+(0.65x8)= 7.9 and Cell 2 should equal 0.28x2=0.56 and so on for each cell in the grid.
I have considered looping through the grid, clipping the lines into a geodataframe, then doing the math, then append it to the column but I have a huge grid and the loop takes a very long time.
I also considered interpolating points along the line based on the speed; the point would represent where the object was at a given hour of its journey. Then using the spatial join count function I would get a rough metric of object time within each grid. Interpolating points based on a column value for that row is turning out to be tricky so I thought I would ask if there was a means of doing it as I outlined above.