本文整理汇总了Python中karta.vector.geometry.Polygon.get_extent方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.get_extent方法的具体用法?Python Polygon.get_extent怎么用?Python Polygon.get_extent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karta.vector.geometry.Polygon
的用法示例。
在下文中一共展示了Polygon.get_extent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_poly_extent_foreign_crs
# 需要导入模块: from karta.vector.geometry import Polygon [as 别名]
# 或者: from karta.vector.geometry.Polygon import get_extent [as 别名]
def test_poly_extent_foreign_crs(self):
poly = Polygon([(0.0, 8.0), (0.0, 5.0), (6.0, 1.0)], crs=LonLatWGS84)
poly3 = Polygon([(0.0, 8.0, 0.5), (0.0, 5.0, 0.8), (6.0, 1.0, 0.6)], crs=LonLatWGS84)
x, y = zip(*poly.get_vertices(crs=NSIDCNorth))
self.assertEqual(poly.get_extent(NSIDCNorth), (min(x), max(x), min(y), max(y)))
self.assertEqual(poly3.get_extent(NSIDCNorth), (min(x), max(x), min(y), max(y)))
return
示例2: TestGeometryAnalysis
# 需要导入模块: from karta.vector.geometry import Polygon [as 别名]
# 或者: from karta.vector.geometry.Polygon import get_extent [as 别名]
#.........这里部分代码省略.........
self.assertTrue(p.isclockwise())
return
def test_poly_counterclockwise(self):
p = Polygon([(0,0), (1,0), (1,1), (0,1)])
self.assertFalse(p.isclockwise())
return
def test_poly_polar(self):
p = Polygon([(0.0, 80.0), (30.0, 80.0), (60.0, 80.0), (90.0, 80.0),
(120.0, 80.0), (150.0, 80.0), (180.0, 80.0),
(-150.0, 80.0), (-120.0, 80.0), (-90.0, 80.0),
(-60.0, 80.0), (-30.0, 80.0)], crs=SphericalEarth)
self.assertTrue(p.ispolar())
p = Polygon([(0.0, 85.0, 0.0), (90.0, 85.0, 0.0), (180.0, 85.0, 0.0),
(-90.0, 85.0, 0.0)], crs=SphericalEarth)
self.assertTrue(p.ispolar())
p = Polygon([(45.0, 30.0), (40.0, 25.0), (45.0, 20.0), (35.0, 25.0)],
crs=SphericalEarth)
self.assertFalse(p.ispolar())
p = Polygon([(-80, 0), (-50, -10), (20, -8), (35, -17), (55, 15),
(-45, 18), (-60, 12)], crs=LonLatWGS84)
self.assertFalse(p.ispolar())
p = Polygon([(45.0, 30.0), (40.0, 25.0), (45.0, 20.0), (35.0, 25.0)],
crs=Cartesian)
self.assertRaises(CRSError, p.ispolar)
return
def test_poly_extent(self):
self.assertEqual(self.poly.get_extent(), (0.0, 6.0, 1.0, 8.0))
self.assertEqual(self.poly3.get_extent(), (0.0, 6.0, 1.0, 8.0))
return
def test_poly_extent_foreign_crs(self):
poly = Polygon([(0.0, 8.0), (0.0, 5.0), (6.0, 1.0)], crs=LonLatWGS84)
poly3 = Polygon([(0.0, 8.0, 0.5), (0.0, 5.0, 0.8), (6.0, 1.0, 0.6)],
crs=LonLatWGS84)
x, y = zip(*poly.get_vertices(crs=NSIDCNorth))
self.assertEqual(poly.get_extent(NSIDCNorth),
(min(x), max(x), min(y), max(y)))
self.assertEqual(poly3.get_extent(NSIDCNorth),
(min(x), max(x), min(y), max(y)))
return
def test_poly_length(self):
self.assertEqual(self.poly.perimeter, 19.430647008220866)
return
def test_poly_contains1(self):
# trivial cases
pt0 = Point((-0.5, 0.92))
self.assertFalse(self.unitsquare.contains(pt0))
pt1 = Point((0.125, 0.875))
self.assertTrue(self.unitsquare.contains(pt1))
x = np.arange(-4, 5)
y = (x)**2
line = Line([(x_,y_) for x_,y_ in zip(x, y)], crs=Cartesian)
bbox = Polygon([(-2.5, 2.5), (2.5, 2.5), (2.5, -2.5), (-2.5, -2.5)],
crs=Cartesian)