Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

http://farm3.static.flickr.com/2738/4511827859_b5822043b7_o_d.png

Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometries. It is not concerned with data formats or coordinate systems. It is based on the widely deployed GEOS (the engine of PostGIS) and JTS (from which GEOS is ported) libraries. This C dependency is traded for the ability to analyze geometries with blazing speed.

In a nutshell: Shapely lets you do PostGIS-ish stuff outside the context of a database using idiomatic Python. For more details, see:

Dependencies

Shapely 1.2 depends on:

  • Python >=2.5,<3

  • libgeos_c >=3.1 (3.0 and below have not been tested, YMMV)

Installation

Windows users should use the executable installer, which contains the required GEOS DLL. Other users should acquire libgeos_c by any means, make sure that it is on the system library path, and install from the Python package index:

$ pip install Shapely

or from a source distribution with the setup script:

$ python setup.py install

Usage

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
313.65484905459385

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

Numpy integration

All linear geometries, such as the rings of a polygon, provide the Numpy array interface:

>>> from numpy import asarray
>>> ag = asarray(patch.exterior)
>>> ag
array([[  1.00000000e+01,   0.00000000e+00],
       [  9.95184727e+00,  -9.80171403e-01],
       [  9.80785280e+00,  -1.95090322e+00],
       ...
       [  1.00000000e+01,   0.00000000e+00]])

That yields a numpy array of [x, y] arrays. This is not exactly what one wants for plotting shapes with Matplotlib, so Shapely 1.2 adds a xy geometry property for getting separate arrays of coordinate x and y values:

>>> x, y = patch.exterior.xy
>>> ax = asarray(x)
>>> ax
array([  1.00000000e+01,   9.95184727e+00,   9.80785280e+00,  ...])

Numpy arrays can also be adapted to Shapely linestrings:

>>> from shapely.geometry import asLineString
>>> asLineString(ag).length
62.806623139095073
>>> asLineString(ag).wkt
'LINESTRING (10.0000000000000000 0.0000000000000000, ...)'

Testing

Shapely uses a Zope-stye suite of unittests and doctests, excercised like:

$ python setup.py test

Support

For current information about this project, see the wiki.

If you have questions, please consider joining our community list:

http://trac.gispython.org/projects/PCL/wiki/CommunityList

Credits

Shapely is written by:

  • Sean Gillies

  • Aron Bierbaum

  • Kai Lautaportti

Patches contributed by:

  • Howard Butler

  • Frédéric Junod

  • Eric Lemoine

  • Jonathan Tartley

  • Kristian Thy

  • Oliver Tonnhofer

Additional help from:

  • Justin Bronn (GeoDjango) for ctypes inspiration

  • Martin Davis (JTS)

  • Sandro Santilli, Mateusz Loskot, Paul Ramsey, et al (GEOS Project)

Major portions of this work were supported by a grant (for Pleiades) from the U.S. National Endowment for the Humanities (http://www.neh.gov).

Metadata

Release files for shapely 1.2b6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shapely 1.2b6
File Size Uploaded Provenance Actions
Shapely-1.2b6.tar.gz 37.9 kB Without provenance Details for Shapely-1.2b6.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for shapely 1.2b6
File Interpreter ABI Platform Actions
Shapely-1.2b6.win32-py2.6.exe Details for Shapely-1.2b6.win32-py2.6.exe
Shapely-1.2b6.win32-py2.5.exe Details for Shapely-1.2b6.win32-py2.5.exe
Shapely-1.2b6.win32-py2.4.exe Details for Shapely-1.2b6.win32-py2.4.exe

Total release size: 2.7 MB

Release files / Shapely-1.2b6.tar.gz

Download URL Shapely-1.2b6.tar.gz
Size 37.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4c80495e927e3b7d29e3f3eee669b931dc57d51e8dd6b56ac7590d8991de8058
BLAKE2b-256 checksum
How to use checksums
09a717d2c96c9f00d28f80d6d25b128c6a7a11ebbbf4a3ddfa2d9ce4bf9abfde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / Shapely-1.2b6.win32-py2.6.exe

Download URL Shapely-1.2b6.win32-py2.6.exe
Size 964.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5ad6221b000fdab61257df838f28e6151ccadb1baab59fe9a99315e104d2c539
BLAKE2b-256 checksum
How to use checksums
2dd6355d54c6e28a43a8690ade31f44758f3b6141c1f57cf5d12934e41e4ed0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / Shapely-1.2b6.win32-py2.5.exe

Download URL Shapely-1.2b6.win32-py2.5.exe
Size 829.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b2a92081329c3ae202f2b4cc5d710940a7e78b1c202af32469f4f52ecf9d2802
BLAKE2b-256 checksum
How to use checksums
e9d36b9d1e8cc3ce8f7e8eedb6425d25072a1dbd47ca41b752cd29681fd259aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / Shapely-1.2b6.win32-py2.4.exe

Download URL Shapely-1.2b6.win32-py2.4.exe
Size 829.4 kB
Tags Source
SHA-256 checksum
How to use checksums
74988dccce2d58254132fe2fb392295738e0f558612e499f40084bdd1b410052
BLAKE2b-256 checksum
How to use checksums
88a6fa3adb0d5c5b35fd27204d07ba7bfede921a841733b05ae651f1404a9d46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for shapely 1.2b6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page