Skip to main content

Geometric objects, predicates, and operations

Project description

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

Project details


Release history Release notifications | RSS feed

This version

1.2.7

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Shapely-1.2.7.tar.gz (56.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

Shapely-1.2.7.win-amd64.exe (1.5 MB view details)

Uploaded Source

Shapely-1.2.7.win32.exe (966.4 kB view details)

Uploaded Source

Shapely-1.2.7-py2.7-win32.egg (813.6 kB view details)

Uploaded Egg

Shapely-1.2.7-py2.6-win32.egg (813.7 kB view details)

Uploaded Egg

Shapely-1.2.7-py2.5-win32.egg (813.8 kB view details)

Uploaded Egg

File details

Details for the file Shapely-1.2.7.tar.gz.

File metadata

  • Download URL: Shapely-1.2.7.tar.gz
  • Upload date:
  • Size: 56.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Shapely-1.2.7.tar.gz
Algorithm Hash digest
SHA256 fa17bae8eae090dcf98e96fb2fc426a4c8da142fbb38a2d8703ed53b524c839a
MD5 2cd0bab00a2c39d1ae6cd9ed648db904
BLAKE2b-256 da3a28e88bd71c9bd7f0b29f50971efe915cc041f1d2268eca8de195d78965c0

See more details on using hashes here.

File details

Details for the file Shapely-1.2.7.win-amd64.exe.

File metadata

File hashes

Hashes for Shapely-1.2.7.win-amd64.exe
Algorithm Hash digest
SHA256 2df2f9194d4df3611d704304e1e5796b5621669fa6a1053aea53832059defed9
MD5 c645a150e69bfa234afadf7d6c5c039a
BLAKE2b-256 7e20ce5497b34a7aa9099fcfa77dce8e0625db9d77babb10196c983399ea14de

See more details on using hashes here.

File details

Details for the file Shapely-1.2.7.win32.exe.

File metadata

  • Download URL: Shapely-1.2.7.win32.exe
  • Upload date:
  • Size: 966.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Shapely-1.2.7.win32.exe
Algorithm Hash digest
SHA256 7a5a86bd88109a06ccefe3d4fa3d1eacd824edad8f4c15dd1cad9b28e489e083
MD5 55847f0c73b71401a39f966c652d58be
BLAKE2b-256 4c537b3dafca771a51c89096646553cd2abdf326a581bdd897ce06e84db7f338

See more details on using hashes here.

File details

Details for the file Shapely-1.2.7-py2.7-win32.egg.

File metadata

File hashes

Hashes for Shapely-1.2.7-py2.7-win32.egg
Algorithm Hash digest
SHA256 73a833c6495006e957a903b6f341e7e7bc29c5918469b5719d3addd4e5a427f2
MD5 b581e58609759f72d3b28a0ed0510c9e
BLAKE2b-256 f30b703262433622c92c15704581f6542965f57a5fd5d82781fe37ee78e18991

See more details on using hashes here.

File details

Details for the file Shapely-1.2.7-py2.6-win32.egg.

File metadata

File hashes

Hashes for Shapely-1.2.7-py2.6-win32.egg
Algorithm Hash digest
SHA256 88e58155cb35d7f6bb2d11b1d54d4047ebc9f82f80d7cfeb7218d9d2289c1497
MD5 c709bb3453c051a9ad013efd4b37c82e
BLAKE2b-256 bddee269610503c14da1ac6aa7bdbf9471ec30b3d9e143bebc60ee5cc9e3069d

See more details on using hashes here.

File details

Details for the file Shapely-1.2.7-py2.5-win32.egg.

File metadata

File hashes

Hashes for Shapely-1.2.7-py2.5-win32.egg
Algorithm Hash digest
SHA256 34fe71f8a8b17895dc9c5aaf85944365cb07b93b673cc7e9a34e01dd2e511edb
MD5 2fcaf48b28f19e9c04ba45d94ffbec9e
BLAKE2b-256 9365d8511cbb623afe98fc1333e4b146b3bc284cccc014b8e948f38b258b9ee3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page