Skip to content

Shapely RuntimeWarning: invalid value encountered in linestrings #41

@pirmink

Description

@pirmink

When running pytrajplot test with the tests/test_pytrajplot.sh script, the following warning messages appear:

<conda-env-prefix>/lib/python3.11/site-packages/shapely/creation.py:119: RuntimeWarning: invalid value encountered in linestrings

Here's what GitHub Copilot says:

You get the warning

shapely/creation.py:119: RuntimeWarning: invalid value encountered in linestrings

because Shapely is trying to create a LineString geometry, but the coordinates you provided contain invalid values—most commonly NaN, None, or inf. This usually happens if your input trajectory data has missing or corrupted longitude/latitude values.

How to fix:
Check your input files (e.g., in zero_lon_from_east, zero_last_lon, etc.) for missing or non-numeric coordinate values. Clean or filter out any rows with invalid data before passing them to pytrajplot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions