本文整理汇总了Python中karta.vector.geometry.Point类的典型用法代码示例。如果您正苦于以下问题:Python Point类的具体用法?Python Point怎么用?Python Point使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Point类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_translate_point_3
def test_translate_point_3(self):
pt = Point((0, 0, 3), crs=Cartesian)
newpt = pt.apply_transform(np.array([[0, 0, 1], [0, 0, 2]]))
self.assertEqual(newpt.x, 1.0)
self.assertEqual(newpt.y, 2.0)
self.assertEqual(newpt.z, 3.0)
return
示例2: test_walk_albers_geodetic
def test_walk_albers_geodetic(self):
AlaskaAlbers = ProjectedCRS("+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 "
"+x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs",
"+ellps=GRS80")
start = Point((-2658638, 2443580), crs=AlaskaAlbers)
dest = start.walk(4500, 195.0, projected=False)
self.assertAlmostEqual(dest.x, -2662670.889, places=3)
self.assertAlmostEqual(dest.y, 2441551.155, places=3)
示例3: test_vertices_in_crs2
def test_vertices_in_crs2(self):
point = Point((-123.0, 49.0), crs=SphericalEarth)
BCAlbers = Proj4CRS("+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 "
"+lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +datum=NAD83 "
"+units=m +no_defs", "+ellps=GRS80")
self.assertEqual(point.get_vertex(BCAlbers),
(1219731.770879303, 447290.49891930853))
return
示例4: test_distance
def test_distance(self):
for crs in (SphericalEarth, LonLatWGS84):
pt0 = Point((0.0, 0.0), crs=crs)
pt1 = Point((-1.0, 1.0), crs=crs)
pt2 = Point((-179.5, 0.0), crs=crs)
pt3 = Point((179.5, 1.0), crs=crs)
self.assertAlmostEqual(pt0.distance(pt1), pt2.distance(pt3), places=8)
示例5: test_vertices_in_crs2
def test_vertices_in_crs2(self):
point = Point((-123.0, 49.0), crs=LonLatWGS84)
BCAlbers = ProjectedCRS("+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 "
"+lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +datum=NAD83 "
"+units=m +no_defs", "BC Albers")
self.assertTupleAlmostEqual(point.vertex(BCAlbers),
(1219731.770879303, 447290.49891930853))
return
示例6: test_walk_albers_projected
def test_walk_albers_projected(self):
AlaskaAlbers = ProjectedCRS("+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 "
"+x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs",
"+ellps=GRS80")
start = Point((-2658638, 2443580), crs=AlaskaAlbers)
dest = start.walk(4500, 195.0)
self.assertAlmostEqual(dest.x, -2659802.686, places=3)
self.assertAlmostEqual(dest.y, 2439233.334, places=3)
return
示例7: test_point_azimuth3
def test_point_azimuth3(self):
""" Verify with:
printf "0 -1000000\n100000 -900000" | proj +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +units=m +datum=WGS84 +no_defs -I -s | tr '\n' ' ' | invgeod +ellps=WGS84 -f "%.6f"
"""
point = Point((0.0, -10e5), crs=NSIDCNorth)
other = Point((1e5, -9e5), crs=NSIDCNorth)
self.assertAlmostEqual(point.azimuth(other, projected=False), 45.036973, places=6)
return
示例8: test_point_write_cartesian
def test_point_write_cartesian(self):
p = Point((100.0, 0.0), crs=Cartesian)
s = p.as_geojson(urn="urn:ogc:def:crs:EPSG::5806", force_wgs84=False)
ans = """{"properties": {},"bbox": [100.0, 0.0, 100.0, 0.0],
"geometry": {"coordinates": [100.0, 0.0], "type": "Point"},
"type": "Feature",
"crs": {"properties": {"name": "urn:ogc:def:crs:EPSG::5806"}, "type": "name"} }"""
self.verifyJSON(s, ans)
return
示例9: test_translate_point
def test_translate_point(self):
pt = Point((0, 0), crs=Cartesian)
with self.assertRaises(ValueError):
newpt = pt.apply_transform(np.array([[0, 0, 1, 0], [0, 0, 2, 0]]))
newpt = pt.apply_transform(np.array([[0, 0, 1], [0, 0, 2]]))
self.assertEqual(newpt.x, 1.0)
self.assertEqual(newpt.y, 2.0)
return
示例10: test_greatcircle_projected
def test_greatcircle_projected(self):
van = Point(self.vancouver.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)
whi = Point(self.whitehorse.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)
ott = Point(self.ottawa.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)
d1 = van.distance(ott, projected=False)
d2 = van.distance(whi, projected=False)
d3 = whi.distance(ott, projected=False)
d4 = whi.distance(van, projected=False)
self.assertAlmostEqual(d1, 3549030.70541, places=3)
self.assertAlmostEqual(d2, 1483327.53922, places=3)
self.assertAlmostEqual(d3, 4151366.88185, places=3)
self.assertAlmostEqual(d4, 1483327.53922, places=3)
return
示例11: setUp
def setUp(self):
self.point = Point((1.0, 2.0, 3.0),
properties={"type": "apple", "color": (43,67,10)})
self.vertices = [(2.0, 9.0, 9.0), (4.0, 1.0, 9.0), (4.0, 1.0, 5.0),
(2.0, 8.0, 0.0), (9.0, 8.0, 4.0), (1.0, 4.0, 6.0),
(7.0, 3.0, 4.0), (2.0, 5.0, 3.0), (1.0, 6.0, 6.0),
(8.0, 1.0, 0.0), (5.0, 5.0, 1.0), (4.0, 5.0, 7.0),
(3.0, 3.0, 5.0), (9.0, 0.0, 9.0), (6.0, 3.0, 8.0),
(4.0, 5.0, 7.0), (9.0, 9.0, 4.0), (1.0, 4.0, 7.0),
(1.0, 7.0, 8.0), (9.0, 1.0, 6.0)]
self.data = [99.0, 2.0, 60.0, 75.0, 71.0, 34.0, 1.0, 49.0, 4.0, 36.0,
47.0, 58.0, 65.0, 72.0, 4.0, 27.0, 52.0, 37.0, 95.0, 17.0]
self.mp = Multipoint(self.vertices, data=self.data)
self.line = Line(self.vertices)
self.poly = Polygon([(0.0, 8.0), (0.0, 5.0), (6.0, 1.0)])
self.poly3 = Polygon([(0.0, 8.0, 0.5), (0.0, 5.0, 0.8), (6.0, 1.0, 0.6)])
self.ring = Polygon([(2.0, 2.0), (4.0, 2.0), (3.0, 6.0)])
self.ringed_poly = Polygon([(0.0, 0.0), (10, 0.0),
(10.0, 10.0), (0.0, 10.0)],
subs=[self.ring])
self.unitsquare = Polygon([(0.0,0.0), (1.0,0.0), (1.0,1.0), (0.0,1.0)])
return
示例12: TestGeometryProj
class TestGeometryProj(unittest.TestCase):
def setUp(self):
self.vancouver = Point((-123.1, 49.25), crs=LonLatWGS84)
self.ottawa = Point((-75.69, 45.42), crs=LonLatWGS84)
self.whitehorse = Point((-135.05, 60.72), crs=LonLatWGS84)
return
def test_greatcircle(self):
d1 = self.vancouver.distance(self.ottawa)
d2 = self.vancouver.distance(self.whitehorse)
d3 = self.whitehorse.distance(self.ottawa)
d4 = self.whitehorse.distance(self.vancouver)
self.assertAlmostEqual(d1, 3549030.70541, places=5)
self.assertAlmostEqual(d2, 1483327.53922, places=5)
self.assertAlmostEqual(d3, 4151366.88185, places=5)
self.assertAlmostEqual(d4, 1483327.53922, places=5)
return
def test_greatcircle_projected(self):
van = Point(self.vancouver.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)
whi = Point(self.whitehorse.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)
ott = Point(self.ottawa.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)
d1 = van.distance(ott, projected=False)
d2 = van.distance(whi, projected=False)
d3 = whi.distance(ott, projected=False)
d4 = whi.distance(van, projected=False)
self.assertAlmostEqual(d1, 3549030.70541, places=3)
self.assertAlmostEqual(d2, 1483327.53922, places=3)
self.assertAlmostEqual(d3, 4151366.88185, places=3)
self.assertAlmostEqual(d4, 1483327.53922, places=3)
return
def test_azimuth_lonlat(self):
""" Verify with
echo "49.25dN 123.1dW 45.42dW 75.69dW" | invgeod +ellps=WGS84 -f "%.6f"
"""
az1 = self.vancouver.azimuth(self.ottawa)
az2 = self.vancouver.azimuth(self.whitehorse)
self.assertAlmostEqual(az1, 78.483344, places=6)
self.assertAlmostEqual(az2, -26.135827, places=6)
return
def test_walk_lonlat(self):
start = Point((-132.14, 54.01), crs=LonLatWGS84)
dest = start.walk(5440.0, 106.8)
self.assertAlmostEqual(dest.x, -132.0605910876)
self.assertAlmostEqual(dest.y, 53.99584742821)
return
示例13: TestGeometryProj
class TestGeometryProj(unittest.TestCase):
def setUp(self):
self.vancouver = Point((-123.1, 49.25), crs=LonLatWGS84)
self.ottawa = Point((-75.69, 45.42), crs=LonLatWGS84)
self.whitehorse = Point((-135.05, 60.72), crs=LonLatWGS84)
return
def test_greatcircle(self):
d1 = self.vancouver.distance(self.ottawa)
d2 = self.vancouver.distance(self.whitehorse)
d3 = self.whitehorse.distance(self.ottawa)
d4 = self.whitehorse.distance(self.vancouver)
self.assertTrue(abs(d1 - 3549030.70541) < 1e-5)
self.assertTrue(abs(d2 - 1483327.53922) < 1e-5)
self.assertTrue(abs(d3 - 4151366.88185) < 1e-5)
self.assertTrue(abs(d4 - 1483327.53922) < 1e-5)
return
def test_azimuth_lonlat(self):
""" Verify with
echo "49.25dN 123.1dW 45.42dW 75.69dW" | invgeod +ellps=WGS84 -f "%.6f"
"""
az1 = self.vancouver.azimuth(self.ottawa)
az2 = self.vancouver.azimuth(self.whitehorse)
self.assertAlmostEqual(az1, 78.483344, places=6)
self.assertAlmostEqual(az2, -26.135827, places=6)
return
def test_walk_lonlat(self):
start = Point((-132.14, 54.01), crs=LonLatWGS84)
dest = start.walk(5440.0, 106.8)
self.assertAlmostEqual(dest.x, -132.0605910876)
self.assertAlmostEqual(dest.y, 53.99584742821)
return
示例14: test_point_azimuth
def test_point_azimuth(self):
point = Point((1.0, 2.0))
other = Point((2.0, 3.0))
self.assertEqual(point.azimuth(other), 0.25*180)
other = Point((0.0, 3.0))
self.assertEqual(point.azimuth(other), -0.25*180)
other = Point((0.0, 1.0))
self.assertEqual(point.azimuth(other), -0.75*180)
other = Point((2.0, 1.0))
self.assertEqual(point.azimuth(other), 0.75*180)
other = Point((1.0, 3.0))
self.assertEqual(point.azimuth(other), 0.0)
other = Point((1.0, 1.0))
self.assertEqual(point.azimuth(other), -180.0)
return
示例15: test_point
def test_point(self):
pt = Point((1,2))
self.assertEqual(pt.__geo_interface__, {"type":"Point", "coordinates":(1,2)})
pt.shift((2,2))
self.assertEqual(pt.__geo_interface__, {"type":"Point", "coordinates":(3,4)})