Skip to content

[MAINT] Update deprecated shapely.ops.cascaded_union to shapely.ops.unary_union #471

Description

@imharrisonking

Maintenance request summary

Calling the solaris.vector.mask.df_to_px_mask function is throwing the below depreciation warning related to shapely.ops.cascaded_union which has been superseded by the more performant shapely.ops.unary_union and deprecated in Shapely 1.8. Proposing that this is updated.

ShapelyDeprecationWarning: The 'cascaded_union()' function is deprecated. Use 'unary_union()' instead.
gs[x['gs_idx']].intersection(cascaded_union(gs[x['intersectors']]))

This is called from solaris/utils/geo.py on line 474:

 output_polys = []
  _ = intersect_lists.apply(lambda x: output_polys.append(
      gs[x['gs_idx']].intersection(cascaded_union(gs[x['intersectors']]))
  ), axis=1)
  # we then generate the union of all of these intersections and return it.
  return cascaded_union(output_polys)

Task detail and notes

Straight swap of cascaded_union for unary_union in geo.py and updating of tutorials and tests that use cascaded_union (see below).

Any additional information:
Not sure what the plans are in terms of moving to a newer version of Shapely in future releases of solaris, or how actively maintained this project is, but I'm loving the solaris.vector.mask.df_to_px_mask function and I'm happy to fork a branch and make the below proposed changes.

  • What other code will this impact?
    Tests:
  • tests/test_tile.py
  • test_geo.py

Tutorials in docs:

  • api_mask_to_vector.ipynb

  • api_masks_tutorial.ipynb

  • Do new tests need to be written or do existing tests need to be updated?

  • Yes, see above

  • Will this impact documentation?

  • Yes, for tutorials, see above

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions