Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geojsoncontour's contourf_to_geojson issue #1462

Closed
charlienegri opened this issue Dec 18, 2024 · 4 comments · Fixed by #1474
Closed

geojsoncontour's contourf_to_geojson issue #1462

charlienegri opened this issue Dec 18, 2024 · 4 comments · Fixed by #1474
Assignees
Milestone

Comments

@charlienegri
Copy link
Collaborator

charlienegri commented Dec 18, 2024

the contourf_to_geojson function call (see https://github.com/metno/pyaerocom/blob/main-dev/pyaerocom/aeroval/modelmaps_helpers.py#L90) fails with the version of the code tagged cams2-83_2024-12.1 (at least for the "onlymap" runs of cams2_83) with the following error

│ /modules/rhel8/user-apps/fou-modules/cams2_83-evaluation/2024-12.1/venv/lib/ │
│ python3.10/site-packages/geojsoncontour/contour.py:81 in contourf_to_geojson │
│                                                                              │
│    78 │   │   variable_opacity = False                                       │
│    79 │   polygon_features = []                                              │
│    80 │   contourf_levels = get_contourf_levels(contourf.levels, contourf.ex │
│ ❱  81 │   for coll, level in zip(contourf.collections, contourf_levels):     │
│    82 │   │   color = coll.get_facecolor()                                   │
│    83 │   │   muli = MP(coll, min_angle_deg, ndigits)                        │
│    84 │   │   polygon = muli.mpoly()                                         │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │           contourf = <cartopy.mpl.contour.GeoContourSet object at        │ │
│ │                      0x14e3f3e20760>                                     │ │
│ │    contourf_levels = [                                                   │ │
│ │                      │   '100.00-125.00',                                │ │
│ │                      │   '125.00-150.00',                                │ │
│ │                      │   '150.00-175.00',                                │ │
│ │                      │   '175.00-200.00',                                │ │
│ │                      │   '200.00-225.00',                                │ │
│ │                      │   '225.00-250.00',                                │ │
│ │                      │   '250.00-275.00',                                │ │
│ │                      │   '275.00-300.00',                                │ │
│ │                      │   '>300.00'                                       │ │
│ │                      ]                                                   │ │
│ │       fill_opacity = 0.9                                                 │ │
│ │ fill_opacity_range = None                                                │ │
│ │   geojson_filepath = None                                                │ │
│ │ geojson_properties = None                                                │ │
│ │      min_angle_deg = None                                                │ │
│ │            ndigits = 5                                                   │ │
│ │   polygon_features = []                                                  │ │
│ │          serialize = True                                                │ │
│ │            strdump = False                                               │ │
│ │       stroke_width = 1                                                   │ │
│ │               unit = ''                                                  │ │
│ │   variable_opacity = False                                               │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'GeoContourSet' object has no attribute 'collections'

I wonder if this might be due to a newer version of geojsoncontour...
in the module where this issue showed up (installed as pip install --force "git+ssh://[email protected]/metno/pyaerocom.git@cams2-83_2024-12.1") I have gotten

Cartopy                        0.24.1
contourpy                      1.3.1
geojson                        3.1.0
geojsoncontour                 0.4.0
matplotlib                     3.10.0
pyproj                         3.7.0
@charlienegri
Copy link
Collaborator Author

as Magnus suggested, this is a geojsoncontour + matplotlib issue https://chat.google.com/room/AAAAvubjk88/wil_lmXeOd8/jkubBxfSPiw?cls=12
pinning matplotlib to < 3.10.0 would be a workaround before geojson is fixed

@magnusuMET magnusuMET mentioned this issue Dec 18, 2024
9 tasks
@magnusuMET
Copy link
Collaborator

See https://discourse.matplotlib.org/t/collections-attribute-deprecation-in-version-3-8/24164 for some discussion on how to fix this (in geojsoncontour)

@magnusuMET
Copy link
Collaborator

See bartromgens/geojsoncontour#27 for a potential fix

@heikoklein heikoklein added this to the m2025-01 milestone Jan 7, 2025
@lewisblake lewisblake modified the milestones: m2025-01, m2025-02 Jan 7, 2025
@lewisblake
Copy link
Member

TODO

  1. release new version of geojsoncontour
  2. Unpin matplotlib
  3. Test this resolves the issue above

@magnusuMET magnusuMET linked a pull request Jan 8, 2025 that will close this issue
9 tasks
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 a pull request may close this issue.

5 participants