本文整理匯總了Python中karta.vector.geometry.Multipoint.within_polygon方法的典型用法代碼示例。如果您正苦於以下問題:Python Multipoint.within_polygon方法的具體用法?Python Multipoint.within_polygon怎麽用?Python Multipoint.within_polygon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類karta.vector.geometry.Multipoint
的用法示例。
在下文中一共展示了Multipoint.within_polygon方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_multipoint_within_polygon
# 需要導入模塊: from karta.vector.geometry import Multipoint [as 別名]
# 或者: from karta.vector.geometry.Multipoint import within_polygon [as 別名]
def test_multipoint_within_polygon(self):
np.random.seed(42)
x = (np.random.random(100) - 0.5) * 180.0
y = (np.random.random(100) - 0.5) * 30.0
xp = [-80, -50, 20, 35, 55, -45, -60]
yp = [0, -10, -8, -17, 15, 18, 12]
poly = Polygon(zip(xp, yp), crs=LonLatWGS84)
mp = Multipoint(zip(x, y), crs=LonLatWGS84)
subset = mp.within_polygon(poly)
excluded = [pt for pt in mp if pt not in subset]
self.assertTrue(all(poly.contains(pt) for pt in subset))
self.assertFalse(any(poly.contains(pt) for pt in excluded))
return