本文整理汇总了Python中shapely.geometry.Point.intersection方法的典型用法代码示例。如果您正苦于以下问题:Python Point.intersection方法的具体用法?Python Point.intersection怎么用?Python Point.intersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shapely.geometry.Point
的用法示例。
在下文中一共展示了Point.intersection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_operations
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import intersection [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: Point
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import intersection [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.intersection(b)
patchc = PolygonPatch(c, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patchc)
ax.set_title('a.intersection(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)
#2
ax = fig.add_subplot(122)
示例3: Point
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import intersection [as 别名]
# new ciclar partial cover, centered at fromNode of lastSeg
temp_bf_shp = Point(lastSeg[-2]).buffer(v1_remain_dis)
writeShp([temp_bf_shp], "buffer_v1.shp")
# generate split line
sl1 = SplitLine_mk2(lastSeg, lastSeg[0], coverage_distance, temp_bf_shp)
# split line from prior split
prior_radi = v1_sLines[-1].cuttingLine
sl2 = SplitLine_mk2((lastSeg[0], list(prior_radi.coords)[1]), lastSeg[0], coverage_distance, temp_bf_shp)
cutting_box_1, cutting_box_2 = cutting_box_mk2(sl1, sl2, temp_bf_shp)
writeShp([cutting_box_1, cutting_box_2], "small_cuttingBox.shp")
s_cutbox = [cutting_box_1, cutting_box_2]
sector = temp_bf_shp.intersection(s_cutbox[0])
v1_remain_dis -= sl1.lineObj.length
v1_esps.remove(v1_esps[0])
v1_sectors.append(sector)
v1_sLines.append(sl1)
# print "end of sub loop"
# raw_input()
if v1_remain_dis > 0:
temp_bf_shp = Point(v1_overlap[0]).buffer(v1_remain_dis)
sl1 = SplitLine_mk2(v1_overlap, v1_overlap[0], coverage_distance, temp_bf_shp)
prior_radi = v1_sLines[-1].cuttingLine
sl2 = SplitLine_mk2((v1_overlap[0], list(prior_radi.coords)[1]), v1_overlap[0], coverage_distance, temp_bf_shp)
cutting_box_1, cutting_box_2 = cutting_box_mk2(sl1, sl2, temp_bf_shp)
s_cutbox = [cutting_box_1, cutting_box_2]
sector = temp_bf_shp.intersection(s_cutbox[0])
示例4: Point
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import intersection [as 别名]
from numpy import sqrt
from shapely.geometry import Point, LineString, LinearRing
pt = Point(0,0)
print 'pt', pt
print 'pt type', pt.geom_type
print 'pt coordinate:', pt.coords[:][0]
#line = LineString([(0,1),(-1,0)])
line = LineString([(-1,-1),(1,1)])
print 'line', line
print 'line type', line.geom_type
print 'line coordinates:', line.coords[:]
print 'line length:', line.length, '== sqrt(2)*2', line.length==sqrt(2)*2
print ''
d = pt.distance(line)
print 'distance:', d
ipt = pt.intersection(line)
print 'ipt type', ipt.geom_type
print ipt
print ''
lr = LinearRing(line.coords[:]+pt.coords[:])
print 'is_ccw', lr.is_ccw
示例5: MultiLineString
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import intersection [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