Search code examples
polygonpointshapely

which algorithm use pyhton shaply library to detect points in polygon?


Which algorithm does Shapely use to detect whether points are inside a polygon? I checked the documentation but couldn't find any specific algorithm mentioned.


Solution

  • Shapely uses the GEOS library under the hood, so if you want to know the algorythm you can check out the GEOS source code:

    Shapely is a Python package for set-theoretic analysis and manipulation of planar features using functions from the well known and widely deployed GEOS library. GEOS, a port of the Java Topology Suite (JTS), is the geometry engine of the PostGIS spatial extension for the PostgreSQL RDBMS. The designs of JTS and GEOS are largely guided by the Open Geospatial Consortium’s Simple Features Access Specification [1] and Shapely adheres mainly to the same set of standard classes and operations.

    Source: shapely user manual, introduction