I have been searching for a python alternative to MATLAB's inpolygon() and I have come across contains_points as a good option.
However, the docs are a little bare with no indication of what type of data contains_points expects:
contains_points(points, transform=None, radius=0.0)Returns a
boolarray which isTrueif the path contains the corresponding point.If transform is not
None, the path will be transformed before performing the test.radius allows the path to be made slightly larger or smaller.
I have the polygon stored as an n*2 numpy array (where n is quite large ~ 500). As far as I can see I need to call the Path() method on this data which seems to work OK:
poly_path = Path(poly_points)
At the moment I also have the points I wish to test stored as another n*2 numpy array (catalog_points).
Perhaps my problem lies here? As when I run:
in_poly = poly_path.contains_points(catalog_points)
I get back an ndarray containing False for every value no matter the set of points I use (I have tested this on arrays of points well within the polygon).

所有评论(0)