• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

Shapely.egg-info/H03-May-2022-1,193941

_vendor/H22-Oct-2021-1,7251,130

docs/H22-Oct-2021-3,4172,419

shapely/H22-Oct-2021-23,11016,742

tests/H03-May-2022-5,8184,232

PKG-INFOH A D22-Oct-202148.6 KiB1,193941

README.rstH A D15-Jul-20215.1 KiB162112

setup.cfgH A D22-Oct-2021124 96

setup.pyH A D21-Oct-202112.8 KiB382243

README.rst

1=======
2Shapely
3=======
4
5|github-actions| |appveyor| |coveralls|
6
7.. |github-actions| image:: https://github.com/Toblerity/Shapely/workflows/Tests%20(Linux)/badge.svg
8   :target: https://github.com/Toblerity/Shapely/actions
9
10.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/Toblerity/Shapely?branch=master&svg=true
11   :target: https://ci.appveyor.com/project/frsci/shapely?branch=master
12
13.. |coveralls| image:: https://coveralls.io/repos/github/Toblerity/Shapely/badge.svg?branch=master
14   :target: https://coveralls.io/github/Toblerity/Shapely?branch=master
15
16Manipulation and analysis of geometric objects in the Cartesian plane.
17
18.. image:: https://c2.staticflickr.com/6/5560/31301790086_b3472ea4e9_c.jpg
19   :width: 800
20   :height: 378
21
22Shapely is a BSD-licensed Python package for manipulation and analysis of
23planar geometric objects. It is based on the widely deployed `GEOS
24<https://trac.osgeo.org/geos/>`__ (the engine of `PostGIS
25<http://postgis.org>`__) and `JTS
26<https://locationtech.github.io/jts/>`__ (from which GEOS is ported)
27libraries. Shapely is not concerned with data formats or coordinate systems,
28but can be readily integrated with packages that are. For more details, see:
29
30* `Shapely GitHub repository <https://github.com/Toblerity/Shapely>`__
31* `Shapely documentation and manual <https://shapely.readthedocs.io/en/latest/>`__
32
33Usage
34=====
35
36Here is the canonical example of building an approximately circular patch by
37buffering a point.
38
39.. code-block:: pycon
40
41    >>> from shapely.geometry import Point
42    >>> patch = Point(0.0, 0.0).buffer(10.0)
43    >>> patch
44    <shapely.geometry.polygon.Polygon object at 0x...>
45    >>> patch.area
46    313.65484905459385
47
48See the manual for more examples and guidance.
49
50Requirements
51============
52
53Shapely 1.8 requires
54
55* Python >=3.6
56* GEOS >=3.3
57
58Installing Shapely
59==================
60
61Shapely may be installed from a source distribution or one of several kinds
62of built distribution.
63
64Built distributions
65-------------------
66
67Built distributions are the only option for users who do not have or do not
68know how to use their platform's compiler and Python SDK, and a good option for
69users who would rather not bother.
70
71Linux, OS X, and Windows users can get Shapely wheels with GEOS included from the
72Python Package Index with a recent version of pip (8+):
73
74.. code-block:: console
75
76    $ pip install shapely
77
78Shapely is available via system package management tools like apt, yum, and
79Homebrew, and is also provided by popular Python distributions like Canopy and
80Anaconda. If you use the Conda package manager to install Shapely, be sure to
81use the conda-forge channel.
82
83Windows users have another good installation options: the wheels published at
84https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely. These can be installed
85using pip by specifying the entire URL.
86
87Source distributions
88--------------------
89
90If you want to build Shapely from source for compatibility with other modules
91that depend on GEOS (such as cartopy or osgeo.ogr) or want to use a different
92version of GEOS than the one included in the project wheels you should first
93install the GEOS library, Cython, and Numpy on your system (using apt, yum,
94brew, or other means) and then direct pip to ignore the binary wheels.
95
96.. code-block:: console
97
98    $ pip install shapely --no-binary shapely
99
100If you've installed GEOS to a standard location, the geos-config program will
101be used to get compiler and linker options. If geos-config is not on your
102executable, it can be specified with a GEOS_CONFIG environment variable, e.g.:
103
104.. code-block:: console
105
106    $ GEOS_CONFIG=/path/to/geos-config pip install shapely
107
108Integration
109===========
110
111Shapely does not read or write data files, but it can serialize and deserialize
112using several well known formats and protocols. The shapely.wkb and shapely.wkt
113modules provide dumpers and loaders inspired by Python's pickle module.
114
115.. code-block:: pycon
116
117    >>> from shapely.wkt import dumps, loads
118    >>> dumps(loads('POINT (0 0)'))
119    'POINT (0.0000000000000000 0.0000000000000000)'
120
121Shapely can also integrate with other Python GIS packages using GeoJSON-like
122dicts.
123
124.. code-block:: pycon
125
126    >>> import json
127    >>> from shapely.geometry import mapping, shape
128    >>> s = shape(json.loads('{"type": "Point", "coordinates": [0.0, 0.0]}'))
129    >>> s
130    <shapely.geometry.point.Point object at 0x...>
131    >>> print(json.dumps(mapping(s)))
132    {"type": "Point", "coordinates": [0.0, 0.0]}
133
134Development and Testing
135=======================
136
137Dependencies for developing Shapely are listed in requirements-dev.txt. Cython
138and Numpy are not required for production installations, only for development.
139Use of a virtual environment is strongly recommended.
140
141.. code-block:: console
142
143    $ virtualenv .
144    $ source bin/activate
145    (env)$ pip install -r requirements-dev.txt
146    (env)$ pip install -e .
147
148The project uses pytest to run Shapely's suite of unittests and doctests.
149
150.. code-block:: console
151
152    (env)$ python -m pytest
153
154Support
155=======
156
157Questions about using Shapely may be asked on the `GIS StackExchange
158<https://gis.stackexchange.com/questions/tagged/shapely>`__ using the "shapely"
159tag.
160
161Bugs may be reported at https://github.com/Toblerity/Shapely/issues.
162