https://pypi.org/project/Shapely/
https://github.com/Toblerity/Shapely
1. Project description
Manipulation and analysis of geometric objects in the Cartesian plane.
2. Requirements
Shapely 1.6 requires:
Python >= 2.6 (including Python 3.x)
GEOS >= 3.3
3. Installing Shapely 1.6
Shapely may be installed from a source distribution or one of several kinds of built distribution.
3.1 Built distributions
OS X and Linux users can get Shapely wheels with GEOS included from the Python Package Index with a recent version of pip (8+):
sudo pip install shapely
A few extra speedups that require Numpy can be had by running
sudo pip install shapely[vectorized]
Shapely is available via system package management tools like apt, yum, and Homebrew, and is also provided by popular Python distributions like Canopy and Anaconda.
3.2 Source distributions
https://pypi.org/project/Shapely/
https://shapely.readthedocs.io/en/latest/
4. 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
>>> patch.area
313.65484905459385
strong@foreverstrong:~$ sudo pip install shapely
[sudo] password for strong:
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/strong/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting shapely
Downloading https://files.pythonhosted.org/packages/a5/cf/0d51a15861d944da8463d8c1aecf39cfc6852ea9ecd092046824e9b237b3/Shapely-1.6.4.post1-cp27-cp27mu-manylinux1_x86_64.whl (1.5MB)
100% |████████████████████████████████| 1.5MB 279kB/s
Installing collected packages: shapely
Successfully installed shapely-1.6.4.post1
strong@foreverstrong:~$
strong@foreverstrong:~$ python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from shapely.geometry import Point
>>> patch = Point(0.0, 0.0).buffer(10.0)
>>> patch
>>> patch.area
313.6548490545939
>>> exit()
strong@foreverstrong:~$ sudo pip install shapely[vectorized]
[sudo] password for strong:
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/strong/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: shapely[vectorized] in /usr/local/lib/python2.7/dist-packages (1.6.4.post1)
Requirement already satisfied: numpy; extra == "vectorized" in ./.local/lib/python2.7/site-packages (from shapely[vectorized]) (1.13.3)
strong@foreverstrong:~$
manipulation [məˌnɪpjuˈleɪʃn]:n. 操纵,操作,处理,篡改
geometric [ˌdʒiːəˈmetrɪk]:adj. 几何学的,几何学图形的
Cartesian [kɑ:ˈti:ziən]:adj. (法国哲学家和数学家) 笛卡儿的,笛卡儿主义的 n. 笛卡儿哲学的信徒
circular [ˈsɜːkjələ(r)]:adj. 循环的,圆形的 n. 通知,传单
canonical [kə'nɒnɪk(ə)l]:adj. 被收入真经篇目的,经典的,按照基督教教会法规的 n. (布道时应穿的) 法衣