当前位置: 首页>>代码示例>>Python>>正文


Python Polygon.get_extent方法代码示例

本文整理汇总了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
开发者ID:acrosby,项目名称:karta,代码行数:9,代码来源:geometry_tests.py

示例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)
开发者ID:ivn888,项目名称:karta,代码行数:69,代码来源:geometry_tests.py


注:本文中的karta.vector.geometry.Polygon.get_extent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。