Manipulation and analysis of geometric objects
Python Shell
Latest commit b7c6f68 Oct 24, 2016 @sgillies sgillies committed on GitHub Merge pull request #425 from dethi/fix/pytest-warning
Fix pytest warning about [pytest] in setup.cfg
Failed to load latest commit information.
DLLs_AMD64_VC9 Directory changes to support new Windows build system Aug 9, 2011
DLLs_x86_VC7 Directory changes to support new Windows build system Aug 9, 2011
DLLs_x86_VC9 Directory changes to support new Windows build system Aug 9, 2011
build-scripts First take on a build script for OS X. Jan 5, 2015
docs Merge pull request #371 from georgeouzou/split Mar 13, 2016
packaging-15.3.dist-info Vendorize packaging Aug 26, 2015
packaging Vendorize packaging Aug 26, 2015
shapely Replace list append with list comprehension Oct 21, 2016
tests Add tests for geointerface of GeometryCollection Oct 21, 2016
tools Directory changes to support new Windows build system Aug 9, 2011
.dockerignore Build manylinux1 wheels Jul 7, 2016
.gitignore Added venv/, .coverage, and ignore/ to .gitignore and use setup.cfg t… Jul 19, 2016
.travis.yml Coveralls Jul 26, 2016
CHANGES.txt Update docstring and change log Aug 31, 2016
CITATION.txt missing `}` Jun 29, 2016 Add code of conduct. Nov 6, 2015
CREDITS.txt Update version, credits, change log Mar 28, 2016
Dockerfile.wheels Build manylinux1 wheels Jul 7, 2016
GEOS-C-API.txt Remove reference to GEOSCoordSeq_getOrdinate (#178) Nov 19, 2008
LICENSE.txt Add new files, increment version to 1.0b1 Nov 20, 2007 _geos.pxi in package_data Aug 31, 2016
README.rst Advice on using --no-binary Oct 6, 2016 Build manylinux1 wheels Jul 7, 2016 Build script for wheels, bump version. Jan 13, 2015
requirements-dev.txt Drop NumPy version requirement from 1.8.0 to 1.4.1 Aug 17, 2015
setup.cfg Remove py.test warning about deprecated [pytest] Oct 21, 2016 _geos.pxi in package_data Aug 31, 2016



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:


Shapely 1.5.x requires

  • Python >=2.6 (including Python 3.x)
  • GEOS >=3.3 (Shapely 1.2.x requires only GEOS 3.1 but YMMV)

Installing Shapely

Windows users have two good installation options: the wheels at and the Anaconda platform's [conda-forge]( channel.

OS X users can get Shapely wheels with GEOS included from the Python Package Index with pip:

$ pip install shapely

If you want to build Shapely from source for compatibility with other modules that depend on GEOS (such as cartopy or osgeo.ogr) you may ignore the binary wheels.

$ pip install shapely --no-binary shapely

Experimental binary wheels are also available for Linux. To get them, use pip --pre shapely. To avoid them, use pip install --pre shapely --no-binary shapely.

In other situations, install geos_c libs and headers by any means (for example, brew install geos on OS X or apt-get install libgeos-dev on Debian/Ubuntu) and install Shapely from the Python package index.

$ pip install 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

If your system's GEOS version is < 3.3.0 you cannot use Shapely 1.3+ and must stick to 1.2.x as shown below.

$ pip install shapely<1.3

Or, if you're using pip 6+

$ pip install shapely~=1.2


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

>>> from shapely.geometry import Point
>>> patch = Point(0.0, 0.0).buffer(10.0)
>>> patch
<shapely.geometry.polygon.Polygon object at 0x...>
>>> patch.area

See the manual for comprehensive usage snippets and the and examples.


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.

>>> from shapely.wkt import dumps, loads
>>> dumps(loads('POINT (0 0)'))
'POINT (0.0000000000000000 0.0000000000000000)'

Shapely can also integrate with other Python GIS packages using GeoJSON-like dicts.

>>> import json
>>> from shapely.geometry import mapping, shape
>>> s = shape(json.loads('{"type": "Point", "coordinates": [0.0, 0.0]}'))
>>> s
<shapely.geometry.point.Point object at 0x...>
>>> print(json.dumps(mapping(s)))
{"type": "Point", "coordinates": [0.0, 0.0]}

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.

$ virtualenv .
$ source bin/activate
(env)$ pip install -r requirements-dev.txt
(env)$ pip install -e .

We use py.test to run Shapely's suite of unittests and doctests.

(env)$ py.test tests

Roadmap and Maintenance

Shapely 1.2.x is a maintenance-only branch which supports Python 2.4-2.6, but not Python 3+. There will be no new features in Shapely 1.2.x and only fixes for major bugs.

Shapely 1.4.x is a maintenance-only branch supporting Pythons 2.7 and 3.3+.


Please discuss Shapely with us at

Bugs may be reported at