Project description

Manipulation and analysis of geometric objects in the Cartesian plane.

Shapely is a BSD-licensed Python package for manipulation and analysis of
planar geometric objects. It is based on the widely deployed GEOS (the engine of PostGIS) and JTS (from which GEOS is ported)
libraries. Shapely is not concerned with data formats or coordinate systems,
but can be readily integrated with packages that are. For more details, see:

Built distributions

OS X and Linux users can get Shapely wheels with GEOS included from the
Python Package Index with a recent version of pip (8+):

$ pip install shapely

A few extra speedups that require Numpy can be had by running

$ pip install shapely[vectorized]

Shapely is available via system package management tools like apt, yum, and
Homebrew, and is also provided by popular Python distributions like Canopy and
Anaconda.

Source distributions

If you want to build Shapely from source for compatibility with
other modules that depend on GEOS (such as cartopy or osgeo.ogr) or want to
use a different version of GEOS than the one included in the project wheels
you should first install the GEOS library, Cython, and Numpy on your system
(using apt, yum, brew, or other means) and then direct pip to ignore the binary
wheels.

$ pip install shapely --no-binary shapely

If you’ve installed GEOS to a standard location, the geos-config program
will be used to get compiler and linker options. If geos-config is not on
your executable, it can be specified with a GEOS_CONFIG environment
variable, e.g.:

$GEOS_CONFIG=/path/to/geos-config pip install shapely

Usage

Here is the canonical example of building an approximately circular patch by
buffering a point.

See the manual for comprehensive usage snippets and the dissolve.py and
intersect.py examples.

Integration

Shapely does not read or write data files, but it can serialize and deserialize
using several well known formats and protocols. The shapely.wkb and shapely.wkt
modules provide dumpers and loaders inspired by Python’s pickle module.

Development and Testing

Dependencies for developing Shapely are listed in requirements-dev.txt. Cython
and Numpy are not required for production installations, only for development.
Use of a virtual environment is strongly recommended.

1.6.1 (2017-09-01)

Reduce log level to debug when reporting on calls to ctypes CDLL() that
don’t succeed and are retried (#515).

Clarification: applications like GeoPandas that need an empty geometry object
should use BaseGeometry() instead of Point() or Polygon(). An
EmptyGeometry class has been added in the master development branch and
will be available in the next non-bugfix release.

1.6.0 (2017-08-21)

Shapely 1.6.0 adds new attributes to existing geometry classes and new
functions (split() and polylabel()) to the shapely.ops module.
Exceptions are consolidated in a shapely.errors module and logging practices
have been improved. Shapely’s optional features depending on Numpy are now
gathered into a requirements set named “vectorized” and these may be installed
like pip install shapely[vectorized].

Much of the work on 1.6.0 was aimed to improve the project’s build and
packaging scripts and to minimize run-time dependencies. Shapely now vendorizes
packaging to use during builds only and never again invokes the geos-config
utility at run-time.

In addition to the changes listed under the alpha and beta pre-releases below,
the following change has been made to the project:

geos-config will now be bypassed when NO_GEOS_CONFIG env var is set. This
allows configuration of Shapely builds on Linux systems that for whatever
reasons do not include the geos-config program (#322).

1.6a1 (2016-09-14)

New features:

A new error derived from NotImplementedError, with a more useful message, is
raised when the GEOS backend doesn’t support a called method (#216).

The project() method of LineString has been extended to LinearRing
geometries (#286).

A new minimum_rotated_rectangle attribute has been added to the base
geometry class (#354).

A new shapely.ops.polylabel() function has been added. It
computes a point suited for labeling concave polygons (#395).

A new shapely.ops.split() function has been added. It splits a
geometry by another geometry of lesser dimension: polygon by line, line by
point (#293, #371).

1.5.16 (2016-05-26)

Packaging: extension modules in the OS X wheels uploaded to PyPI link only
libgeos_c.dylib now (you can verify and compare to previous releases with
otool -L shapely/vectorized/_vectorized.so).

1.5.15 (2016-03-29)

Bug fix: use uintptr_t to store pointers instead of long in _geos.pxi,
preventing an overflow error (#372, #373). Note that this bug fix was
erroneously reported to have been made in 1.5.14, but was not.

1.5.14 (2016-03-27)

Bug fix: use type() instead of isinstance() when evaluating geometry
equality, preventing instances of base and derived classes from
being mistaken for equals (#317).

Bug fix: ensure that empty geometries are created when constructors have no
args (#332, #333).

Bug fix: support app “freezing” better on Windows by not relying on the
__file__ attribute (#342, #377).

1.0.5 (2008-05-20)

1.0.4 (2008-05-01)

Disentangle Python and topological equality (#163).

Add shape(), a factory that copies coordinates from a geo interface provider.
To be used instead of asShape() unless you really need to store coordinates
outside shapely for efficient use in other code.