Skip to content

Instantly share code, notes, and snippets.

@wolframalpha
Created October 7, 2019 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolframalpha/850b6d4fb4816e936288db10d848a1ff to your computer and use it in GitHub Desktop.
Save wolframalpha/850b6d4fb4816e936288db10d848a1ff to your computer and use it in GitHub Desktop.
Check if a point is in the polygon
# please install shapely first by `pip install Shapely`
from shapely.geometry import Point
from shapely.geometry.polygon import Polygon
point = Point(0.5, 0.5)
polygon = Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])
# this return a bool
print(polygon.contains(point))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment