Skip to main content

Shapely is a Python package for manipulation and analysis of 2D geospatial geometries. It is based on GEOS (http://geos.refractions.net). Shapely 1.0 is not concerned with data formats or coordinate reference systems. Responsibility for reading and writing data and projecting coordinates is left to other packages like WorldMill and pyproj. For more information, see:

Shapely requires Python 2.4+. (I’ve also begun to port it to Python 3.0: http://zcologia.com/news/564/shapely-for-python-3-0/.)

See also CHANGES.txt and HISTORY.txt.

Dependencies

  • libgeos_c (2.2.3 or 3.0.0+)

  • Python ctypes (standard in Python 2.5+)

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:

$ sudo easy_install Shapely

with the setup script:

$ sudo python setup.py install

or by using the development buildout on Linux, which also provides libgeos_c:

$ svn co http://svn.gispython.org/svn/gispy/buildout/shapely.buildout/trunk shapely.buildout
$ cd shapely.buildout
$ python bootstrap.py
$ ./bin/buildout

Usage

To buffer a point:

>>> from shapely.geometry import Point
>>> point = Point(-106.0, 40.0) # longitude, latitude
>>> point.buffer(10.0)
<shapely.geometry.polygon.Polygon object at ...>

See the manual for comprehensive examples of usage. See also Operations.txt and Predicates.txt under tests/ for more examples of the spatial operations and predicates provided by Shapely. See also Point.txt, LineString.txt, etc for examples of the geometry APIs.

Numpy integration

All Shapely geometry instances provide the Numpy array interface:

>>> from numpy import asarray
>>> a = asarray(point)
>>> a.size
3
>>> a.shape
(2,)

Numpy arrays can also be adapted to Shapely points and linestrings:

>>> from shapely.geometry import asLineString
>>> a = array([[1.0, 2.0], [3.0, 4.0]])
>>> line = asLineString(a)
>>> line.wkt
'LINESTRING (1.0000000000000000 2.0000000000000000, 3.0000000000000000 4.0000000000000000)'

Python Geo Interface

Any object that provides the Python geo interface can be adapted to a Shapely geometry with the asShape factory:

>>> d = {"type": "Point", "coordinates": (0.0, 0.0)}
>>> from shapely.geometry import asShape
>>> shape = asShape(d)
>>> shape.geom_type
'Point'
>>> tuple(shape.coords)
((0.0, 0.0),)

>>> class GeoThing(object):
...     def __init__(self, d):
...         self.__geo_interface__ = d
>>> thing = GeoThing({"type": "Point", "coordinates": (0.0, 0.0)})
>>> shape = asShape(thing)
>>> shape.geom_type
'Point'
>>> tuple(shape.coords)
((0.0, 0.0),)

See http://trac.gispython.org/projects/PCL/wiki/PythonGeoInterface for more details on the interface.

Testing

Several of the modules have docstring doctests:

$ cd shapely
$ python point.py

There are also two test runners under tests/. test_doctests.py requires zope.testing. runalldoctests.py does not. Perhaps the easiest way to run the tests is:

$ 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

  • Sean Gillies (Pleiades)

  • Howard Butler (Hobu, Inc.)

  • Kai Lautaportti (Hexagon IT)

  • Frédéric Junod (Camptocamp SA)

  • Eric Lemoine (Camptocamp SA)

  • Justin Bronn (GeoDjango) for ctypes inspiration

  • Artem Pavlenko (Mapnik) for help with GEOS DLLs

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

Release files for shapely 1.0.5

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.0.5
File Size Uploaded
Shapely-1.0.5.tar.gz 34.3 kB Details

Release files / Shapely-1.0.5.tar.gz

Download URL Shapely-1.0.5.tar.gz
Size 34.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b3662ddf5d88ecfbbdbb20d5dc14013c94ad2eae34681d9e00bf58a3ad638e70
BLAKE2b-256 checksum
How to use checksums
32afd208f3ae131dd53388b74ff08efbce97161e87e2aa6f0580ad3c18180803
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

1.2.4

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

This release

1.0.5 This release

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