question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clip with Polygon causes IndexError: list index out of range

See original GitHub issue

I am trying to add the clip approach in the 2-ship-data.ipynb notebook by adding below the get_intersecting chunk the following:

all_trajectories = traj_collection.trajectories
arrivals = [ traj.clip(area_of_interest) for traj in all_trajectories ] 

And I am getting the following error & I cannot understand why ?

 15        if type(row['spatial_intersection']) == LineString:
 16         -> pt0 = Point(row['spatial_intersection'].coords[0])
 17             ptn = Point(row['spatial_intersection'].coords[-1])
 18             t = row['prev_t']

IndexError: list index out of range

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
wendellwtcommented, Mar 29, 2021

Thank you!! It works fine now.

1reaction
anitagrasercommented, Mar 29, 2021

I think a check of empty linestring is required in the calculation of spatial_intersections

You’re right. That did the trick. Thank you both for your help!

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python IndexError: List Index Out of Range [Easy Fix] - Finxter
To solve the “IndexError: list index out of range”, avoid do not access a non-existing list index. For example, my_list[5] causes an error...
Read more >
List index out of range error - GIS Stack Exchange
I've been writing a script that clips large datasets based on a ... are active I get the error "Runtime error : list...
Read more >
List Index Out of Range – Python Error Message Solved
You'll get the Indexerror: list index out of range error when iterating through a list and trying to access an item that doesn't...
Read more >
What is causing this list index out of range error with pandas ...
I'm using 7 functions to create dot density maps in Python, Pandas, and Geopandas. The functions read the US Census blockgroups and create ......
Read more >
How to Fix IndexError in Python - Rollbar
This error occurs when an attempt is made to access an item in a list at an index which is out of bounds....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found