I am making a convex hull using the scipy.spatial
package http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.ConvexHull.html#scipy.spatial.ConvexHull
I've tried searching, but have yet to know if there is an easy way to find if any point (latitude/longitude) lies inside the convex hull. Any suggestions?
The method that I've used before is using the Path
class matplotlib
. This has a contains_point
method which does exactly that. As well as a contains_points
which allows you to query an array of points.
To use this you would do
from scipy.spatial import ConvexHull
from matplotlib.path import Path
hull = ConvexHull( points )
hull_path = Path( points[hull.vertices] )
print hull_path.contains_point((1,2)) # Is (1,2) in the convex hull?