Generated by GPT-5-mini| Shapely | |
|---|---|
| Name | Shapely |
| Developer | Sean Gillies |
| Released | 2008 |
| Programming language | Python (programming language) |
| Operating system | Cross-platform software |
| License | BSD license |
| Repository | GitHub |
Shapely
Shapely is a Python library for manipulation and analysis of planar geometric objects, enabling creation, manipulation, and querying of points, lines, and polygons. It integrates with libraries and tools such as GEOS, NumPy, SciPy, Matplotlib, pandas and GDAL to support spatial workflows used by practitioners familiar with PostGIS, QGIS, ArcGIS, and GeoPandas. Shapely is used in environments ranging from Jupyter Notebook research notebooks to production services hosted on Amazon Web Services, Google Cloud Platform, and Microsoft Azure.
Shapely provides geometric primitives—Point, LineString, LinearRing, Polygon, MultiPoint, MultiLineString, MultiPolygon—and implements spatial operations via bindings to the GEOS C++ library. It complements raster-focused projects like Rasterio and vector-focused ecosystems like GeoPandas and Fiona. The project is historically associated with contributors from the Open Source Geospatial Foundation community and is commonly referenced alongside PROJ for coordinate transformations performed by pyproj.
Shapely exposes operations including spatial predicates (e.g., intersects, contains, touches), set-theoretic operations (union, intersection, difference, symmetric_difference), and geometric computations (buffer, centroid, bounds, convex_hull, envelope, simplify). These capabilities are analogous to functions available in PostGIS and are frequently used together with pandas for table-driven spatial processing or with Matplotlib for visualization and with Bokeh or Plotly for interactive mapping. Shapely also interoperates with geospatial standards implemented by OGC and with data formats handled by GeoJSON and WKT.
Shapely can be installed via PyPI using pip and is also available through distribution channels such as conda and Linux distribution package managers. Installation typically requires a compatible GEOS library; binary wheels simplify deployment on Windows, macOS, and Linux. Users integrating Shapely into environments with Django or Flask web applications, or deploying to Docker containers, should verify binary compatibility with target CPython or PyPy runtimes and with continuous integration services like Travis CI or GitHub Actions.
Typical usage patterns demonstrate creation of geometries from coordinate lists or from text formats like WKT and GeoJSON, spatial predicates for filtering with pandas DataFrames, and topology-preserving operations for geoprocessing workflows comparable to those executed in QGIS or ArcGIS. Examples often show integration with Geopandas for reading shapefiles via Fiona and for plotting with Matplotlib or exporting results for web mapping stacks like Leaflet or OpenLayers. Shapely is used in geocoding pipelines alongside Geopy and in routing applications integrated with OSRM or GraphHopper.
Shapely's API mirrors the object model of the GEOS kernel, exposing geometry classes and methods for spatial operations and geometric properties. Under the hood, Shapely relies on C-level bindings to GEOS and provides Pythonic wrappers for memory management and type conversions, facilitating use with NumPy arrays and Cython-accelerated extensions. The library's design allows interoperability with spatial databases like PostGIS and with serialization formats consumed by GeoJSON-aware web services and MapServer or GeoServer deployments.
Shapely's development has involved maintainers and contributors from the geospatial open-source community, with source code hosted on GitHub and issue tracking supported via GitHub Issues. The project receives contributions and discussions across platforms including the Open Source Geospatial Foundation mailing lists, Stack Overflow, and geospatial-focused conferences such as FOSS4G and State of the Map. Shapely integrates into broader projects like GeoPandas and is cited in academic work alongside toolchains involving Jupyter Notebook, SciPy, and NumPy.
Shapely is distributed under a permissive BSD license, enabling commercial and academic use, redistribution, and inclusion in software stacks deployed on services such as Docker Hub, PyPI, and Anaconda. Packaging and redistribution follow common practices for Python scientific libraries and honor upstream dependencies including GEOS and PROJ.
Category:Geographic information systems Category:Python (programming language) libraries