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


Python geometry.Line类代码示例

本文整理汇总了Python中karta.vector.geometry.Line的典型用法代码示例。如果您正苦于以下问题:Python Line类的具体用法?Python Line怎么用?Python Line使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Line类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        self.points = [Point((1, 1), data={"species": "T. officianale"}, crs=LonLatWGS84),
                       Point((3, 1), data={"species": "C. tectorum"}, crs=LonLatWGS84),
                       Point((4, 3), data={"species": "M. alba"}, crs=LonLatWGS84),
                       Point((2, 2), data={"species": "V. cracca"}, crs=LonLatWGS84)]

        self.multipoint = Multipoint([(1,1), (3,1), (4,3), (2,2)],
                                     data={"species": ["T. officianale", "C. tectorum",
                                                       "M. alba", "V. cracca"]},
                                     crs=LonLatWGS84)

        self.line = Line([(1.0,5.0),(5.0,5.0),(5.0,1.0),(3.0,3.0),(1.0,1.0)],
                         properties={"geom_id": 27, "name": "test line"},
                         crs=LonLatWGS84)

        self.polygon = Polygon([(1.0,5.0),(5.0,5.0),(5.0,1.0),(3.0,3.0),(1.0,1.0)],
                               crs=LonLatWGS84)

        self.points3 = [Point((1, 1, 0), crs=LonLatWGS84),
                        Point((3, 1, 3), crs=LonLatWGS84),
                        Point((4, 3, 2), crs=LonLatWGS84),
                        Point((2, 2, -1), crs=LonLatWGS84)]

        self.line3 = Line([(1,5,2),(5,5,-1),(5,1,3),(3,3,1),(1,1,0)], crs=LonLatWGS84)

        self.polygon3 = Polygon([(1,5,2),(5,5,-1),(5,1,3),(3,3,1),(1,1,0)], crs=LonLatWGS84)

        testfiles = ["points.shp", "line.shp", "polygon.shp"]
        if any(not exists(join(TMPDATA, "shapefiles/", fnm)) for fnm in testfiles):
            self.saveTestData()
        return
开发者ID:acrosby,项目名称:karta,代码行数:31,代码来源:shapefile_tests.py

示例2: test_long_attribute_names

    def test_long_attribute_names(self):
        line = Line([(1.0,5.0),(5.0,5.0),(5.0,1.0),(3.0,3.0),(1.0,1.0)],
                    properties={
                        "geom_id": 27,
                        "name": "test line",
                        "description": "line for testing",
                        "description_en": "Line for testing."
                        },
                    crs=LonLatWGS84)

        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            line.to_shapefile(os.path.join(TESTDIR, "data/line_truncated_attr"))

        for fnm in ("line_truncated_attr.shx",
                    "line_truncated_attr.shx",
                    "line_truncated_attr.dbf",
                    "line_truncated_attr.prj"):
            self.assertTrue(os.path.isfile(os.path.join(TESTDIR, "data", fnm)))

        line2 = read_shapefile(os.path.join(TESTDIR, "data", "line_truncated_attr"))[0]
        self.assertTrue("DESCRIPTIO" in line2.properties)
        self.assertTrue("DESCRIPTI2" in line2.properties)
        self.assertTrue("GEOM_ID" in line2.properties)
        self.assertTrue("NAME" in line2.properties)
开发者ID:fortyninemaps,项目名称:karta,代码行数:25,代码来源:shapefile_tests.py

示例3: test_line_append3d

 def test_line_append3d(self):
     ln0 = Line([(3.0, 3.0, 2.0), (5.0, 1.0, 0.0), (3.0, 1.0, 5.0)])
     ln1 = Line([(3.0, 3.0, 2.0), (5.0, 1.0, 0.0), (3.0, 1.0, 5.0),
                 (0.0, 1.0, 3.0)])
     ln0.append(Point((0.0, 1.0, 3.0)))
     self.assertEqual(ln0, ln1)
     return
开发者ID:jmjak86,项目名称:karta,代码行数:7,代码来源:geometry_tests.py

示例4: test_to_npoints_lonlat

 def test_to_npoints_lonlat(self):
     line = Line([(0, 40), (120, 40)], crs=LonLatWGS84)
     points = line.to_npoints(20)
     ans = [Point(v, crs=LonLatWGS84) for v in [(0, 40),
                               (4.006549675732082, 43.200316625343305),
                               (8.44359845345209, 46.2434129228378),
                               (13.382442375999254, 49.09308515921458),
                               (18.894149336762318, 51.705248417290484),
                               (25.03918819127435, 54.027440893063556),
                               (31.85052685770255, 55.99968253476488),
                               (39.31083346558522, 57.55771841446013),
                               (47.329401349484314, 58.6395037346357),
                               (55.7308352362257, 59.194673757153645),
                               (64.26916476377436, 59.19467375715364),
                               (72.67059865051574, 58.639503734635674),
                               (80.68916653441482, 57.557718414460105),
                               (88.14947314229748, 55.999682534764844),
                               (94.96081180872568, 54.02744089306352),
                               (101.10585066323772, 51.705248417290456),
                               (106.61755762400078, 49.09308515921457),
                               (111.55640154654793, 46.24341292283779),
                               (115.99345032426793, 43.2003166253433),
                               (120, 40)]]
     for a,b in zip(points, ans):
         self.assertPointAlmostEqual(a, b)
     return
开发者ID:fortyninemaps,项目名称:karta,代码行数:26,代码来源:geometry_tests.py

示例5: test_line_write

    def test_line_write(self):
        p = Line([(100.0, 0.0), (101.0, 1.0)], crs=LonLatWGS84)
        s = p.as_geojson(urn="urn:ogc:def:crs:EPSG::5806")
        ans = """{ "type": "Feature", "properties": {}, "geometry": { "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::5806" } }, "coordinates": [ [ 100.0, 0.0 ], [ 101.0, 1.0 ] ], "type": "LineString" } }"""

        self.verifyJson(s, ans)
        return
开发者ID:ivn888,项目名称:karta,代码行数:7,代码来源:geojson_tests.py

示例6: test_line_extend

 def test_line_extend(self):
     ln0a = Line([(3.0, 3.0, 2.0), (5.0, 1.0, 0.0), (3.0, 1.0, 5.0)])
     ln0b = Line([(4.0, 4.0, 6.0), (0.0, 1.0, 3.0)])
     ln1 = Line([(3.0, 3.0, 2.0), (5.0, 1.0, 0.0), (3.0, 1.0, 5.0),
                 (4.0, 4.0, 6.0), (0.0, 1.0, 3.0)])
     ln0a.extend(ln0b)
     self.assertEqual(ln0a, ln1)
开发者ID:fortyninemaps,项目名称:karta,代码行数:7,代码来源:geometry_tests.py

示例7: test_to_npoints_cartesian

 def test_to_npoints_cartesian(self):
     line = Line([(0.0, 0.0), (1.0, 2.0), (3.0, -2.0), (4.0, -1.0),
                  (4.0, 3.0), (3.0, 2.0)])
     points = line.to_npoints(20)
     ans = [Point(v) for v in [(0.0, 0.0),
                               (0.318619234003536, 0.637238468007072),
                               (0.637238468007072, 1.274476936014144),
                               (0.9558577020106079, 1.9117154040212159),
                               (1.274476936014144, 1.4510461279717122),
                               (1.59309617001768, 0.8138076599646402),
                               (1.911715404021216, 0.17656919195756826),
                               (2.230334638024752, -0.4606692760495037),
                               (2.5489538720282883, -1.0979077440565757),
                               (2.867573106031824, -1.7351462120636478),
                               (3.294395938694146, -1.7056040613058538),
                               (3.7981771815888177, -1.2018228184111823),
                               (4.0, -0.5729663008226373),
                               (4.0, 0.13948796534818164),
                               (4.0, 0.8519422315190006),
                               (4.0, 1.5643964976898195),
                               (4.0, 2.2768507638606383),
                               (4.0, 2.989305030031457),
                               (3.5037812428946715, 2.503781242894671),
                               (3.0, 2.0)]]
     for a,b in zip(points, ans):
         self.assertPointAlmostEqual(a, b)
     return
开发者ID:fortyninemaps,项目名称:karta,代码行数:27,代码来源:geometry_tests.py

示例8: test_multipoint_subset

 def test_multipoint_subset(self):
     mp = Multipoint(self.vertices, data=self.data)
     line = Line(self.vertices)
     ss1 = mp._subset(range(2,7))
     ss2 = line._subset(range(2,7))
     self.assertTrue(isinstance(ss1, Multipoint))
     self.assertTrue(isinstance(ss2, Line))
     return
开发者ID:fortyninemaps,项目名称:karta,代码行数:8,代码来源:geometry_tests.py

示例9: test_line_output

 def test_line_output(self):
     p = Line([(4, 2), (3, 5), (3, 2), (7, 3)])
     sp = shapely.geometry.shape(p.geomdict)
     x, y = p.coords()
     sx, sy = sp.xy
     self.assertTrue(np.all(x == np.array(sx)))
     self.assertTrue(np.all(y == np.array(sy)))
     return
开发者ID:fortyninemaps,项目名称:karta,代码行数:8,代码来源:geointerface_tests.py

示例10: test_vertices_in_crs3

 def test_vertices_in_crs3(self):
     line = Line([(2.0, 34.0),
                  (2.15, 34.2),
                  (2.7, 34.1)], crs=SphericalEarth)
     UTM31N = Proj4CRS("+proj=utm +zone=31 +ellps=WGS84 "
                 "+datum=WGS84 +units=m +no_defs", "+ellps=WGS84")
     self.assertEqual(line.get_coordinate_lists(UTM31N),
                 ((407650.39665729366, 421687.71905896586, 472328.1095127584), 
                  (3762606.6598763773, 3784658.467084308, 3773284.485241791)))
     return
开发者ID:jmjak86,项目名称:karta,代码行数:10,代码来源:geometry_tests.py

示例11: test_to_points_cartesian

 def test_to_points_cartesian(self):
     line = Line([(0.0, 0.0), (4.0, 3.0), (1.0, 7.0)])
     points = line.to_points(1.0)
     ans = [(0., 0.), (0.8, 0.6), (1.6, 1.2), (2.4, 1.8), (3.2, 2.4),
            (4., 3.), (3.4, 3.8), (2.8, 4.6), (2.2, 5.4), (1.6, 6.2),
            (1., 7.)]
     self.assertEqual(len(points), len(ans))
     for pt, vert in zip(points, ans):
         self.assertAlmostEqual(pt.x, vert[0])
         self.assertAlmostEqual(pt.y, vert[1])
     return
开发者ID:fortyninemaps,项目名称:karta,代码行数:11,代码来源:geometry_tests.py

示例12: test_line_intersection2

 def test_line_intersection2(self):
     # test lines that have overlapping bounding boxes, but don't cross
     #   -----
     #   | -----
     #   |     |
     #   ----- |
     #     -----
     line0 = Line([(0.0, 0.0), (3.0, 0.0), (3.0, 3.0), (0.0, 3.0)])
     line1 = Line([(1.0, 4.0), (-2.0, 4.0), (-2.0, 1.0), (1.0, 1.0)])
     self.assertFalse(line0.intersects(line1))
     return
开发者ID:fortyninemaps,项目名称:karta,代码行数:11,代码来源:vector_predicate_tests.py

示例13: test_to_npoints_lonlat_precision

    def test_to_npoints_lonlat_precision(self):

        line = Line([(-20.247017, 79.683933), (-20.0993, 79.887917),
            (-19.13705, 80.048567), (-18.680467, 80.089333), (-17.451917,
                80.14405), (-16.913233, 80.02715), (-16.631367, 80.022933),
            (-16.194067, 80.0168), (-15.915983, 80.020267), (-15.7763,
                80.021283)], crs=LonLatWGS84)

        for n in range(2, 30):
            self.assertEqual(len(line.to_npoints(n)), n)
        return
开发者ID:fortyninemaps,项目名称:karta,代码行数:11,代码来源:geometry_tests.py

示例14: test_vertices_in_crs3

 def test_vertices_in_crs3(self):
     line = Line([(2.0, 34.0),
                  (2.15, 34.2),
                  (2.7, 34.1)], crs=LonLatWGS84)
     UTM31N = ProjectedCRS("+proj=utm +zone=31 +ellps=WGS84 "
                 "+datum=WGS84 +units=m +no_defs", "UTM 31N (WGS 84)")
     ans = [[407650.39665729, 3762606.65987638],
            [421687.71905897, 3784658.46708431],
            [472328.10951276, 3773284.48524179]]
     for v0, v1 in zip(line.vertices(UTM31N), ans):
         self.assertTupleAlmostEqual(v0, v1, places=6)
     return
开发者ID:fortyninemaps,项目名称:karta,代码行数:12,代码来源:geometry_tests.py

示例15: test_write_reproject

    def test_write_reproject(self):
        # tests whether coordinates are correctly reprojected to WGS84 lon/lat
        p = Line([(1e6, 1e6), (1.2e6, 1.4e6)], crs=WebMercator)
        s = p.as_geojson()
        ans = """{ "type": "Feature", "properties": {},
            "geometry": {
                "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
                "coordinates": [[8.983152841195214, 8.946573850543412],
                                [10.779783409434257, 12.476624651238847]],
                "type": "LineString" } }"""

        self.verifyJson(s, ans)
        return
开发者ID:ivn888,项目名称:karta,代码行数:13,代码来源:geojson_tests.py


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