Skip to content

Build the points before pickling - #15

Merged
cleemansen merged 1 commit into
mainfrom
feature/1419-materialize-pickle-geometry
Oct 6, 2026
Merged

cleemansen merged 1 commit into
mainfrom
feature/1419-materialize-pickle-geometry

Conversation

@cleemansen

@cleemansen cleemansen commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Since move2_loc to MovingPandas v7 (v2.2.0) the next Python App can crash: the pickled trajectories carry no point locations.

v2.2.0 lifted the movingpandas=0.17.2 pin. Since movingpandas 0.22, a TrajectoryCollection built from x/y keeps its geometry None and builds it on demand — but only inside movingpandas' own methods. The pickle carries that state. Readers touching trajectory.df.geometry directly get None:

  • develop: Stop Detector and Visualizer (movingpandas 0.18.1) → AttributeError: 'NoneType' object has no attribute 'x' in TrajectoryStopDetector._process_traj.
  • production: Behavioral Annotation / Segmentation v3 (current movingpandas, reads trajectory.df itself) → has no valid geometry for UTM conversion, twice since 2026-09-30.

Not related to gzip — both logs show the pickle read correctly.

Change

create_moving_pandas builds the GeoDataFrame with points_from_xy itself and hands it to movingpandas without x/y. The output no longer depends on the writer's movingpandas version.

coords_x/coords_y are dropped, as movingpandas 0.17.2 did (v6). v7 handed them over in addition.

Verification

  • New test test_it_should_write_trajectories_with_point_locations: red before the fix (3265 of 3265 geometries None), green after; swapping x/y fails it.
  • test/Dockerfile with a fresh resolution (Python 3.14.7, pandas 2.3.3): 11 tests OK.
  • Pickle from this branch read with movingpandas 0.18.1 and 0.23.0: no missing geometry, TrajectoryStopDetector finds the same 157 stops in both.

Follow-up

Tag v2.2.1 after merge, new App version of move2_loc to MovingPandas, then bring the fix via main into v3 (feature/port-to-moveapps-package, v8 has the same bug).

Trello: https://trello.com/c/O8xHQ571

movingpandas 0.22 stopped building points from `x`/`y`: the geometry
stays None and is built on demand, inside movingpandas' own methods
only. v2.2.0 lifted the 0.17.2 pin, so every pickle it writes carries
no locations. Readers touching `trajectory.df.geometry` directly
crash - movingpandas < 0.22 in `TrajectoryStopDetector` (Stop
Detector, develop) and Apps on any version in their own code
(Behavioral Annotation / Segmentation, production).

Building the GeoDataFrame here makes the output independent of the
writer's movingpandas and restores what 0.17.2 handed over, without
`coords_x`/`coords_y`.

Trello #1419.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cleemansen
cleemansen requested a review from annescharf October 6, 2026 11:45
@cleemansen
cleemansen merged commit 6291443 into main Oct 6, 2026
1 check passed
cleemansen added a commit that referenced this pull request Oct 6, 2026
Brings v2.2.1 (#15, Trello #1419) onto v3: v3.0.0-RC1 locks
movingpandas 0.23.0 and wrote the same pickles without locations.

transform_to_pickle.py merged cleanly; the dropped-track warning
still reads `data`, which keeps `coords_x`/`coords_y`. The test
conflict was two additions side by side. `pytz` stays out - v3
removed it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant