shapely 1.2.19


pip install shapely==1.2.19

Project Links

Meta
Author: Sean Gillies

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers
  • Science/Research

License
  • OSI Approved :: BSD License

Operating System
  • OS Independent

Programming Language
  • Python

Topic
  • Scientific/Engineering :: GIS

PostGIS-ish operations outside a database context for Pythoneers and Pythonistas.

http://farm3.staticflickr.com/2738/4511827859_b5822043b7_o_d.png

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. This C dependency is traded for the ability to execute with blazing speed. Shapely is not concerned with data formats or coordinate systems, but can be readily integrated with packages that are. 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 (for example), so Shapely 1.2 adds a xy property for obtaining 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, ...)'

Shapely can also integrate with other Python GIS packages using data modeled after GeoJSON.

>>> 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]}

Testing

Shapely uses a Zope-stye suite of unittests and doctests, exercised 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

Please discuss Shapely with us at http://lists.gispython.org/mailman/listinfo/community.

Bugs may be reported at https://github.com/Toblerity/Shapely.

Credits

Shapely is written by:

  • Sean Gillies

  • Aron Bierbaum

  • Kai Lautaportti

  • Oliver Tonnhofer

Patches contributed by:

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

Changes

1.2.19 (2013-12-30)

  • Add buffering style options (#55).

1.2.18 (2013-07-23)

  • Add shapely.ops.transform.

  • Permit empty sequences in collection constructors (#49, #50).

  • Individual polygons in MultiPolygon.__geo_interface__ are changed to tuples to match Polygon.__geo_interface__ (#51).

  • Add shapely.ops.polygonize_full (#57).

1.2.17 (2013-01-27)

  • Avoid circular import between wkt/wkb and geometry.base by moving calls to GEOS serializers to the latter module.

  • Set _ndim when unpickling (issue #6).

  • Don’t install DLLs to Python’s DLL directory (#37).

  • Add affinity module of affine transformation (#31).

  • Fix NameError that blocked installation with PyPy (#40, #41).

1.2.16 (2012-09-18)

  • Add ops.unary_union function.

  • Alias ops.cascaded_union to ops.unary_union when GEOS CAPI >= (1,7,0).

  • Add geos_version_string attribute to shapely.geos.

  • Ensure parent is set when child geometry is accessed.

  • Generate _speedups.c using Cython when building from repo when missing, stale, or the build target is “sdist”.

  • The is_simple predicate of invalid, self-intersecting linear rings now returns False.

  • Remove VERSION.txt from repo, it’s now written by the distutils setup script with value of shapely.__version__.

1.2.15 (2012-06-27)

  • Eliminate numerical sensitivity in a method chaining test (Debian bug #663210).

  • Account for cascaded union of random buffered test points being a polygon or multipolygon (Debian bug #666655).

  • Use Cython to build speedups if it is installed.

  • Avoid stumbling over SVN revision numbers in GEOS C API version strings.

1.2.14 (2012-01-23)

  • A geometry’s coords property is now sliceable, yielding a list of coordinate values.

  • Homogeneous collections are now sliceable, yielding a new collection of the same type.

1.2.13 (2011-09-16)

  • Fixed errors in speedups on 32bit systems when GEOS references memory above 2GB.

  • Add shapely.__version__ attribute.

  • Update the manual.

1.2.12 (2011-08-15)

  • Build Windows distributions with VC7 or VC9 as appropriate.

  • More verbose report on failure to speed up.

  • Fix for prepared geometries broken in 1.2.11.

  • DO NOT INSTALL 1.2.11

1.2.11 (2011-08-04)

  • Ignore AttributeError during exit.

  • PyPy 1.5 support.

  • Prevent operation on prepared geometry crasher (#12).

  • Optional Cython speedups for Windows.

  • Linux 3 platform support.

1.2.10 (2011-05-09)

  • Add optional Cython speedups.

  • Add is_cww predicate to LinearRing.

  • Add function that forces orientation of Polygons.

  • Disable build of speedups on Windows pending packaging work.

1.2.9 (2011-03-31)

  • Remove extra glob import.

  • Move examples to shapely.examples.

  • Add box() constructor for rectangular polygons.

  • Fix extraneous imports.

1.2.8 (2011-12-03)

  • New parallel_offset method (#6).

  • Support for Python 2.4.

1.2.7 (2010-11-05)

  • Support for Windows eggs.

1.2.6 (2010-10-21)

  • The geoms property of an empty collection yields [] instead of a ValueError (#3).

  • The coords and geometry type sproperties have the same behavior as above.

  • Ensure that z values carry through into products of operations (#4).

1.2.5 (2010-09-19)

  • Stop distributing docs/_build.

  • Include library fallbacks in test_dlls.py for linux platform.

1.2.4 (2010-09-09)

  • Raise AttributeError when there’s no backend support for a method.

  • Raise OSError if libgeos_c.so (or variants) can’t be found and loaded.

  • Add geos_c DLL loading support for linux platforms where find_library doesn’t work.

1.2.3 (2010-08-17)

  • Add mapping function.

  • Fix problem with GEOSisValidReason symbol for GEOS < 3.1.

1.2.2 (2010-07-23)

  • Add representative_point method.

1.2.1 (2010-06-23)

  • Fixed bounds of singular polygons.

  • Added shapely.validation.explain_validity function (#226).

1.2 (2010-05-27)

  • Final release.

1.2rc2 (2010-05-26)

  • Add examples and tests to MANIFEST.in.

  • Release candidate 2.

1.2rc1 (2010-05-25)

  • Release candidate.

1.2b7 (2010-04-22)

  • Memory leak associated with new empty geometry state fixed.

1.2b6 (2010-04-13)

  • Broken GeometryCollection fixed.

1.2b5 (2010-04-09)

  • Objects can be constructed from others of the same type, thereby making copies. Collections can be constructed from sequences of objects, also making copies.

  • Collections are now iterators over their component objects.

  • New code for manual figures, using the descartes package.

1.2b4 (2010-03-19)

  • Adds support for the “sunos5” platform.

1.2b3 (2010-02-28)

  • Only provide simplification implementations for GEOS C API >= 1.5.

1.2b2 (2010-02-19)

  • Fix cascaded_union bug introduced in 1.2b1 (#212).

1.2b1 (2010-02-18)

  • Update the README. Remove cruft from setup.py. Add some version 1.2 metadata regarding required Python version (>=2.5,<3) and external dependency (libgeos_c >= 3.1).

1.2a6 (2010-02-09)

  • Add accessor for separate arrays of X and Y values (#210).

TODO: fill gap here

1.2a1 (2010-01-20)

  • Proper prototyping of WKB writer, and avoidance of errors on 64-bit systems (#191).

  • Prototype libgeos_c functions in a way that lets py2exe apps import shapely (#189).

1.2 Branched (2009-09-19)

1.0.12 (2009-04-09)

  • Fix for references held by topology and predicate descriptors.

1.0.11 (2008-11-20)

  • Work around bug in GEOS 2.2.3, GEOSCoordSeq_getOrdinate not exported properly (#178).

1.0.10 (2008-11-17)

  • Fixed compatibility with GEOS 2.2.3 that was broken in 1.0.8 release (#176).

1.0.9 (2008-11-16)

  • Find and load MacPorts libgeos.

1.0.8 (2008-11-01)

  • Fill out GEOS function result and argument types to prevent faults on a 64-bit arch.

1.0.7 (2008-08-22)

  • Polygon rings now have the same dimensions as parent (#168).

  • Eliminated reference cycles in polygons (#169).

1.0.6 (2008-07-10)

  • Fixed adaptation of multi polygon data.

  • Raise exceptions earlier from binary predicates.

  • Beginning distributing new windows DLLs (#166).

1.0.5 (2008-05-20)

  • Added access to GEOS polygonizer function.

  • Raise exception when insufficient coordinate tuples are passed to LinearRing constructor (#164).

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.

  • Cache GEOS geometries in adapters (#163).

1.0.3 (2008-04-09)

  • Do not release GIL when calling GEOS functions (#158).

  • Prevent faults when chaining multiple GEOS operators (#159).

1.0.2 (2008-02-26)

  • Fix loss of dimensionality in polygon rings (#155).

1.0.1 (2008-02-08)

  • Allow chaining expressions involving coordinate sequences and geometry parts (#151).

  • Protect against abnormal use of coordinate accessors (#152).

  • Coordinate sequences now implement the numpy array protocol (#153).

1.0 (2008-01-18)

  • Final release.

1.0 RC2 (2008-01-16)

  • Added temporary solution for #149.

1.0 RC1 (2008-01-14)

  • First release candidate

2.1.1 May 19, 2025
2.1.0 Apr 03, 2025
2.1.0rc1 Mar 15, 2025
2.0.7 Jan 31, 2025
2.0.6 Aug 19, 2024
2.0.5 Jul 13, 2024
2.0.4 Apr 16, 2024
2.0.3 Feb 16, 2024
2.0.2 Oct 12, 2023
2.0.1 Jan 30, 2023
2.0.0 Dec 12, 2022
2.0rc3 Dec 07, 2022
2.0rc2 Dec 03, 2022
2.0rc1 Nov 26, 2022
2.0b2 Oct 29, 2022
2.0b1 Oct 17, 2022
2.0a1 Aug 03, 2022
1.8.5.post1 Oct 13, 2022
1.8.5 Oct 12, 2022
1.8.4 Aug 17, 2022
1.8.3 Aug 17, 2022
1.8.2 May 03, 2022
1.8.1.post1 Feb 18, 2022
1.8.1 Feb 16, 2022
1.8.0 Oct 25, 2021
1.8rc2 Oct 19, 2021
1.8rc1 Oct 04, 2021
1.8a3 Aug 24, 2021
1.8a2 Jul 15, 2021
1.8a1 Mar 04, 2021
1.7.1 Aug 20, 2020
1.7.0 Jan 28, 2020
1.7b1 Jan 13, 2020
1.7a3 Dec 31, 2019
1.7a2 Jun 22, 2019
1.7a1 Jul 29, 2018
1.6.4.post2 Jul 18, 2018
1.6.4.post1 Jan 24, 2018
1.6.4 Jan 24, 2018
1.6.3 Dec 09, 2017
1.6.2.post1 Oct 31, 2017
1.6.2 Oct 26, 2017
1.6.1 Sep 01, 2017
1.6.0 Aug 22, 2017
1.6b5 Aug 18, 2017
1.6b4 Feb 15, 2017
1.6b3 Dec 31, 2016
1.6b2 Dec 12, 2016
1.6b1 Dec 12, 2016
1.6a2 Nov 15, 2016
1.6a1 Sep 14, 2016
1.6.dev0 Jul 11, 2016
1.5.17.post1 Dec 23, 2016
1.5.17 Aug 31, 2016
1.5.16 May 27, 2016
1.5.15 Mar 29, 2016
1.5.14 Mar 28, 2016
1.5.13 Oct 10, 2015
1.5.12 Aug 27, 2015
1.5.11 Aug 23, 2015
1.5.10 Aug 23, 2015
1.5.9 May 28, 2015
1.5.8 Apr 29, 2015
1.5.7 Mar 16, 2015
1.5.6 Feb 04, 2015
1.5.5 Jan 20, 2015
1.5.4 Jan 19, 2015
1.5.3 Jan 13, 2015
1.5.2 Jan 04, 2015
1.5.1 Dec 04, 2014
1.5.0 Dec 02, 2014
1.4.4 Nov 03, 2014
1.4.3 Oct 01, 2014
1.4.2 Sep 29, 2014
1.4.1 Sep 24, 2014
1.4.0 Sep 09, 2014
1.3.3 Jul 23, 2014
1.3.2 May 13, 2014
1.3.1 Apr 22, 2014
1.3.0 Dec 31, 2013
1.2.19 Dec 30, 2013
1.2.18 Jul 23, 2013
1.2.17 Jan 27, 2013
1.2.16 Sep 18, 2012
1.2.15 Jun 28, 2012
1.2.14 Jan 24, 2012
1.2.13 Sep 16, 2011
1.2.12 Aug 15, 2011
1.2.10 May 16, 2011
1.2.9 Apr 01, 2011
1.2.8 Jan 03, 2011
1.2.7 Nov 09, 2010
1.2.6 Oct 21, 2010
1.2.5 Sep 19, 2010
1.2.4 Sep 16, 2010
1.2.3 Aug 19, 2010
1.2.2 Jul 23, 2010
1.2.1 Jun 24, 2010
1.2 May 27, 2010
1.2rc2 May 26, 2010
1.2rc1 May 25, 2010
1.2b7 Apr 22, 2010
1.2b6 Apr 13, 2010
1.2b5 Apr 09, 2010
1.2b4 Mar 19, 2010
1.2b3 Feb 28, 2010
1.2b2 Feb 19, 2010
1.2b1 Feb 18, 2010
1.0.15 Mar 20, 2010
1.0.14 Oct 22, 2009
1.0.13 Oct 02, 2009
1.0.12 Apr 09, 2009
1.0.11 Nov 20, 2008
1.0.7 Aug 23, 2008
1.0.6 Jul 10, 2008
1.0.5 May 20, 2008
1.0.4 May 01, 2008
1.0.3 Apr 09, 2008
1.0.2 Feb 26, 2008
1.0.1 Feb 08, 2008
1.0 Jan 18, 2008
1.0rc2 Jan 16, 2008
1.0rc1 Jan 14, 2008
1.0b4 Jan 04, 2008
1.0b3 Jan 02, 2008
1.0b2 Nov 27, 2007
1.0b1 Nov 20, 2007
1.0a7 Oct 23, 2007
0.0rc0 Oct 23, 2007
No dependencies