How to determine which points are inside of a polygon and which are not (large number of points)?

前端 未结 2 1864
刺人心
刺人心 2021-02-07 02:23

I\'ve got a large set of data points (100,000+) stored in a 2-dimensional numpy array (1st column: x coordinates, 2nd column: y coordinates). I\'ve also got several 1-dimensiona

2条回答
  •  广开言路
    2021-02-07 02:35

    Use matplotlib.nxutils.points_inside_poly, which implements a very efficient test.

    Examples and further explanation of this 40-year-old algorithm at the matplotlib FAQ.

    Update: Note that points_inside_poly is deprecated since version 1.2.0 of matplotlib. Use matplotlib.path.Path.contains_points instead.

提交回复
热议问题