本文整理汇总了Python中shapely.geometry.Point.union方法的典型用法代码示例。如果您正苦于以下问题:Python Point.union方法的具体用法?Python Point.union怎么用?Python Point.union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shapely.geometry.Point
的用法示例。
在下文中一共展示了Point.union方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_operations
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import union [as 别名]
def test_operations(self):
point = Point(0.0, 0.0)
# General geometry
self.assertEqual(point.area, 0.0)
self.assertEqual(point.length, 0.0)
self.assertAlmostEqual(point.distance(Point(-1.0, -1.0)),
1.4142135623730951)
# Topology operations
# Envelope
self.assertIsInstance(point.envelope, Point)
# Intersection
self.assertIsInstance(point.intersection(Point(-1, -1)),
GeometryCollection)
# Buffer
self.assertIsInstance(point.buffer(10.0), Polygon)
self.assertIsInstance(point.buffer(10.0, 32), Polygon)
# Simplify
p = loads('POLYGON ((120 120, 121 121, 122 122, 220 120, 180 199, '
'160 200, 140 199, 120 120))')
expected = loads('POLYGON ((120 120, 140 199, 160 200, 180 199, '
'220 120, 120 120))')
s = p.simplify(10.0, preserve_topology=False)
self.assertTrue(s.equals_exact(expected, 0.001))
p = loads('POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200),'
'(120 120, 220 120, 180 199, 160 200, 140 199, 120 120))')
expected = loads(
'POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200),'
'(120 120, 220 120, 180 199, 160 200, 140 199, 120 120))')
s = p.simplify(10.0, preserve_topology=True)
self.assertTrue(s.equals_exact(expected, 0.001))
# Convex Hull
self.assertIsInstance(point.convex_hull, Point)
# Differences
self.assertIsInstance(point.difference(Point(-1, 1)), Point)
self.assertIsInstance(point.symmetric_difference(Point(-1, 1)),
MultiPoint)
# Boundary
self.assertIsInstance(point.boundary, GeometryCollection)
# Union
self.assertIsInstance(point.union(Point(-1, 1)), MultiPoint)
self.assertIsInstance(point.representative_point(), Point)
self.assertIsInstance(point.centroid, Point)
# Relate
self.assertEqual(point.relate(Point(-1, -1)), 'FF0FFF0F2')
示例2: test_point
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import union [as 别名]
def test_point(self):
point = Point(0, 0)
point2 = Point(-1, 1)
self.assertTrue(point.union(point2).equals(point | point2))
self.assertTrue((point & point2).is_empty)
self.assertTrue(point.equals(point - point2))
self.assertTrue(
point.symmetric_difference(point2).equals(point ^ point2))
示例3: Point
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import union [as 别名]
BLUE = '#6699cc'
GRAY = '#999999'
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
a = Point(1, 1).buffer(1.5)
b = Point(2, 1).buffer(1.5)
# 1
ax = fig.add_subplot(121)
patch1 = PolygonPatch(a, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch1)
patch2 = PolygonPatch(b, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch2)
c = a.union(b)
patchc = PolygonPatch(c, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patchc)
ax.set_title('a.union(b)')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
def plot_line(ax, ob, color=GRAY):
x, y = ob.xy
示例4: MultiLineString
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import union [as 别名]
# -*- coding: utf-8 -*-
import os
from shapely.geometry import Point, LineString, LinearRing, Polygon, MultiLineString
coords = [((0,0),(1,1)),((-1,0),(1,0))]
lines = MultiLineString(coords)
lines.boundary
print(list(lines.boundary))
lines.boundary.boundary.is_empty
LineString([(0,0),(1,1)]).centroid
LineString([(0,0),(1,1)]).centroid.wkt
a = Point(1,1).buffer(1.5)
b = Point(2,1).buffer(1.5)
a.difference(b)
a.intersection(b)
a.symmetric_difference(b)
a.union(b)
a.union(b).boundary
a.boundary.union(b.boundary)
def Test():
assert True