Skip to main content

GEOS wrapped in numpy ufuncs

Project description

Documentation Status Github Actions status Travis CI status PyPI Anaconda Zenodo

PyGEOS is a C/Python library with vectorized geometry functions. The geometry operations are done in the open-source geometry library GEOS. PyGEOS wraps these operations in NumPy ufuncs providing a performance improvement when operating on arrays of geometries.

Important note: PyGEOS was merged with Shapely ( in December 2021 and will be released as part of Shapely 2.0. The development will take place at the Shapely repository. Please raise issues or create pull request over there. PyGEOS itself will receive updates (by backporting from the Shapely repository) until Shapely 2.0 is actually released.

What is a ufunc?

A universal function (or ufunc for short) is a function that operates on n-dimensional arrays in an element-by-element fashion, supporting array broadcasting. The for-loops that are involved are fully implemented in C diminishing the overhead of the Python interpreter.


PyGEOS functions support multithreading. More specifically, the Global Interpreter Lock (GIL) is released during function execution. Normally in Python, the GIL prevents multiple threads from computing at the same time. PyGEOS functions internally releases this constraint so that the heavy lifting done by GEOS can be done in parallel, from a single Python process.


Compare an grid of points with a polygon:

>>> geoms = points(*np.indices((4, 4)))
>>> polygon = box(0, 0, 2, 2)

>>> contains(polygon, geoms)

  array([[False, False, False, False],
         [False,  True, False, False],
         [False, False, False, False],
         [False, False, False, False]])

Compute the area of all possible intersections of two lists of polygons:

>>> from pygeos import box, area, intersection

>>> polygons_x = box(range(5), 0, range(10, 15), 10)
>>> polygons_y = box(0, range(5), 10, range(10, 15))

>>> area(intersection(polygons_x[:, np.newaxis], polygons_y[np.newaxis, :]))

array([[100.,  90.,  80.,  70.,  60.],
     [ 90.,  81.,  72.,  63.,  54.],
     [ 80.,  72.,  64.,  56.,  48.],
     [ 70.,  63.,  56.,  49.,  42.],
     [ 60.,  54.,  48.,  42.,  36.]])

See the documentation for more:


Project details

Download files

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

Source Distribution

pygeos-0.14.tar.gz (141.3 kB view hashes)

Uploaded source

Built Distributions

pygeos-0.14-cp311-cp311-win_amd64.whl (1.4 MB view hashes)

Uploaded cp311

pygeos-0.14-cp311-cp311-win32.whl (1.3 MB view hashes)

Uploaded cp311

pygeos-0.14-cp310-cp310-win_amd64.whl (1.4 MB view hashes)

Uploaded cp310

pygeos-0.14-cp310-cp310-win32.whl (1.3 MB view hashes)

Uploaded cp310

pygeos-0.14-cp39-cp39-win_amd64.whl (1.4 MB view hashes)

Uploaded cp39

pygeos-0.14-cp39-cp39-win32.whl (1.3 MB view hashes)

Uploaded cp39

pygeos-0.14-cp38-cp38-win_amd64.whl (1.5 MB view hashes)

Uploaded cp38

pygeos-0.14-cp38-cp38-win32.whl (1.3 MB view hashes)

Uploaded cp38

pygeos-0.14-cp37-cp37m-win_amd64.whl (1.5 MB view hashes)

Uploaded cp37

pygeos-0.14-cp37-cp37m-win32.whl (1.3 MB view hashes)

Uploaded cp37

Supported by

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