Skip to main content
http://farm3.static.flickr.com/2738/4511827859_b5822043b7_o_d.png

Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects. 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 execute 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.

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.:

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

All linear objects, such as the rings of a polygon (like patch above), 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 always exactly what one wants for plotting shapes with Matplotlib, so Shapely 1.2 adds a xy 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 via setup.py.:

$ python setup.py test

Nosetests won’t run the tests properly; Zope doctest suites are not currently supported well by nose.

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)

  • Jaakko Salli for the Windows distributions

  • 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).

Release files for shapely 1.2.4

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.2.4
File Size Uploaded
Shapely-1.2.4.tar.gz 71.0 kB Details

Release files / Shapely-1.2.4.tar.gz

Download URL Shapely-1.2.4.tar.gz
Size 71.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a5291c2f82afef20ee8f7c17b37b3a264736aa301e83934e6fba4a069d462f2a
BLAKE2b-256 checksum
How to use checksums
4f7905a1867173c02aff9d006db428f9343a68028d660985e640f284da577297
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

2.1.2

57 release files

2.1.1

41 release files

2.0.7

42 release files

2.0.6

42 release files

2.0.5

36 release files

2.0.4

41 release files

2.0.3

41 release files

2.0.2

41 release files

2.0.1

38 release files

2.0.0

38 release files

1.8.5

34 release files

1.8.4

34 release files

1.8.3

31 release files

1.8.1

26 release files

1.8.0

21 release files

1.7.1

23 release files

1.7.0

19 release files

1.6.4

10 release files

1.6.2

6 release files

1.6.1

6 release files

1.6.0

6 release files

1.5.17

4 release files

1.5.16

4 release files

1.5.15

4 release files

1.5.14

4 release files

1.5.13

4 release files

1.5.12

3 release files

1.5.11

3 release files

1.5.10

3 release files

1.5.9

3 release files

1.5.8

3 release files

1.5.7

3 release files

1.5.6

3 release files

1.5.5

3 release files

1.5.4

3 release files

1.5.3

3 release files

1.5.2

2 release files

1.5.1

1 release file

1.5.0

1 release file

1.4.4

1 release file

1.4.3

1 release file

1.4.2

1 release file

1.4.1

1 release file

1.3.3

11 release files

1.3.2

5 release files

1.3.1

5 release files

1.3.0

5 release files

1.2.19

1 release file

1.2.18

9 release files

1.2.17

5 release files

1.2.16

1 release file

1.2.15

1 release file

1.2.10

8 release files

1.2.9

8 release files

1.2.8

8 release files

1.2.7

6 release files

1.2.6

3 release files

1.2.5

3 release files

This release

1.2.4 This release

1 release file

1.2.3

3 release files

1.2.2

3 release files

1.2.1

3 release files

1.2

3 release files

1.0.15

1 release file

1.0.13

1 release file

1.0.11

2 release files

1.0.8

1 release file

1.0.7

2 release files

1.0.6

2 release files

1.0.5

1 release file

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

3 release files

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