Jump to content

Shapely 2.0.0 Released


Lurker

Recommended Posts

Shapely 2.0 version is a major release featuring a complete refactor of the internals and new vectorized (element-wise) array operations, providing considerable performance improvements (based on the developments in the PyGEOS package), along with several breaking API changes and many feature improvements.

 

Refactor of the internals#

Shapely wraps the GEOS C++ library for use in Python. Before 2.0, Shapely used ctypes to link to GEOS at runtime, but doing so resulted in extra overhead and installation challenges. With 2.0, the internals of Shapely have been refactored to expose GEOS functionality through a Python C extension module that is compiled in advance.

Vectorized (element-wise) geometry operations

Before the 2.0 release, Shapely only provided an interface for scalar (individual) geometry objects. Users had to loop over individual geometries within an array of geometries and call scalar methods or properties, which is both more verbose to use and has a large performance overhead.

Shapely 2.0 API changes (deprecated in 1.8)

The Shapely 1.8 release included several deprecation warnings about API changes that would happen in Shapely 2.0 and that can be fixed in your code (making it compatible with both <=1.8 and >=2.0). See Migrating to Shapely 1.8 / 2.0 for more details on how to update your code.

It is highly recommended to first upgrade to Shapely 1.8 and resolve all deprecation warnings before upgrading to Shapely 2.0.

Summary of changes:

  • Geometries are now immutable and hashable.

  • Multi-part geometries such as MultiPolygon no longer behave as “sequences”. This means that they no longer have a length, are not iterable, and are not indexable anymore. Use the .geoms attribute instead to access individual parts of a multi-part geometry.

  • Geometry objects no longer directly implement the numpy array interface to expose their coordinates. To convert to an array of coordinates, use the .coords attribute instead (np.asarray(geom.coords)).

  • The following attributes and methods on the Geometry classes were previously deprecated and are now removed from Shapely 2.0:

    • array_interface() and ctypes

    • asShape(), and the adapters classes to create geometry-like proxy objects (use shape() instead).

    • empty() method

 

source:

Version 2.x — Shapely 2.0.0 documentation

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.

Disable-Adblock.png

 

If you enjoy our contents, support us by Disable ads Blocker or add GIS-area to your ads blocker whitelist