本文整理汇总了Python中shapely.geometry.Point.touches方法的典型用法代码示例。如果您正苦于以下问题:Python Point.touches方法的具体用法?Python Point.touches怎么用?Python Point.touches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shapely.geometry.Point
的用法示例。
在下文中一共展示了Point.touches方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_binary_predicates
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import touches [as 别名]
def test_binary_predicates(self):
point = Point(0.0, 0.0)
self.assertTrue(point.disjoint(Point(-1.0, -1.0)))
self.assertFalse(point.touches(Point(-1.0, -1.0)))
self.assertFalse(point.crosses(Point(-1.0, -1.0)))
self.assertFalse(point.within(Point(-1.0, -1.0)))
self.assertFalse(point.contains(Point(-1.0, -1.0)))
self.assertFalse(point.equals(Point(-1.0, -1.0)))
self.assertFalse(point.touches(Point(-1.0, -1.0)))
self.assertTrue(point.equals(Point(0.0, 0.0)))
示例2: find_dangles
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import touches [as 别名]
def find_dangles(lines):
"""
Locate all dangles
:param lines: list of Shapely LineStrings or MultiLineStrings
:return: list of dangles
"""
list_dangles = []
for i, line in enumerate(lines):
# each line gets a number
# go through each line added first to second
# then second to third and so on
shply_lines = lines[:i] + lines[i+1:]
# 0 is start point and -1 is end point
# run through
for start_end in [0, -1]:
# convert line to point
node = Point(line.coords[start_end])
# Return True if any element of the iterable is true.
# https://docs.python.org/2/library/functions.html#any
# python boolean evaluation comparison
if any(node.touches(next_line) for next_line in shply_lines):
continue
else:
list_dangles.append(node)
return list_dangles
示例3: SpatialToplogy
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import touches [as 别名]
def SpatialToplogy (Spatial_A,Spatial_B):
if Spatial_A[4] == 'Point' and Spatial_B[4]== 'Point':
Point_0=Point(Spatial_A[0],Spatial_A[1])
Point_1=Point(Spatial_B[0],Spatial_B[1])
#Point to point relationships
if Point_0.equals(Point_1): return 'Point1 equals Point2'
if Point_0.within(Point_1.buffer(2)): return 'Point1 lies within a buffer of 2 m from Point2'
if Point_0.overlaps(Point_1): return 'Point1 overlaps Point2'
#if Point_0.disjoint(Point_1): return 'Point1 disjoint Point2'
#Point to line relationships
if Spatial_A[4] == 'Point' and Spatial_B[4]== 'Line':
Point_0=Point(Spatial_A[0],Spatial_A[1])
Line_0=LineString([(Spatial_B[0],Spatial_B[1]),(Spatial_B[2],Spatial_B[3])])
if Point_0.touches(Line_0):return 'Point1 touches Line1'
if Point_0.within(Line_0.buffer(2)):return 'Point1 lies within a buffer of 2 m from L1'
#Point to polygon relationships
if Spatial_A[4] == 'Point' and Spatial_B[4]== 'Polygon':
Point_0=Point(Spatial_A[0],Spatial_A[1])
Polygon_0=Polygon([(Spatial_B[0],Spatial_B[1]),(Spatial_B[2],Spatial_B[1]),(Spatial_B[2],Spatial_B[3]),(Spatial_B[0],Spatial_B[3])])
if Point_0.touches(Polygon_0):return 'Point1 touches Polygon1'
if Point_0.within(Polygon_0):return'Point1 lies within Polygon1'
if Point_0.overlaps(Polygon_0):return 'Point1 lies overlaps Polygon1'
#Line to line relationships
if Spatial_A[4]=='Line' and Spatial_B[4]=='Line':
Line_0=LineString([(Spatial_A[0],Spatial_A[1]),(Spatial_A[2],Spatial_A[3])])
Line_1=LineString([(Spatial_B[0],Spatial_B[1]),(Spatial_B[2],Spatial_B[3])])
if Line_0.equals(Line_1):return 'Line0 equals Line1'
if Line_0.touches(Line_1):return 'Line0 touches Line1'
if Line_0.crosses(Line_1):return 'Line0 crosses Line1'
if Line_0.within(Line_1.buffer(2)):return 'Line0 lies within a buffer of 2 m Line1'
if Line_0.overlaps(Line_1):return 'Line0 overlaps Line1'
#Line to polygon relationships
if Spatial_A[4]=='Line' and Spatial_B[4]=='Polygon':
Line_0=LineString([(Spatial_A[0],Spatial_A[1]),(Spatial_A[2],Spatial_A[3])])
Polygon_0=Polygon([(Spatial_B[0],Spatial_B[1]),(Spatial_B[2],Spatial_B[1]),(Spatial_B[2],Spatial_B[3]),(Spatial_B[0],Spatial_B[3])])
if Line_0.touches(Polygon_0):return 'Line0 touches Polygon1'
if Line_0.crosses(Polygon_0):return 'Line0 crosses Polygon1'
if Line_0.within(Polygon_0):return 'Line0 lies within Polygon1'
#Polygon to Polygon relationships
if Spatial_A[4]=='Polygon' and Spatial_B[4]=='Polygon':
Polygon_0=Polygon([(Spatial_A[0],Spatial_A[1]),(Spatial_A[2],Spatial_A[1]),(Spatial_A[2],Spatial_A[3]),(Spatial_A[0],Spatial_A[3])])
Polygon_1=Polygon([(Spatial_B[0],Spatial_B[1]),(Spatial_B[2],Spatial_B[1]),(Spatial_B[2],Spatial_B[3]),(Spatial_B[0],Spatial_B[3])])
if Polygon_0.touches(Polygon_1):return 'Polygon touches Polygon1'
if Polygon_0.equals(Polygon_1):return 'Polygon0 equals Polygon1'
if Polygon_0.within(Polygon_1):return 'Polygon lies within Polygon1'
if Polygon_0.within(Polygon_1.buffer(2)):return 'Polygon lies within a buffer of 2m Polygon1'
示例4: find_isolated_endpoints
# 需要导入模块: from shapely.geometry import Point [as 别名]
# 或者: from shapely.geometry.Point import touches [as 别名]
def find_isolated_endpoints(lines):
"""Find endpoints of lines that don't touch another line.
Args:
lines: a list of LineStrings or a MultiLineString
Returns:
A list of line end Points that don't touch any other line of lines
"""
isolated_endpoints = []
for i, line in enumerate(lines):
other_lines = lines[:i] + lines[i+1:]
for q in [0,-1]:
endpoint = Point(line.coords[q])
if any(endpoint.touches(another_line)
for another_line in other_lines):
continue
else:
isolated_endpoints.append(endpoint)
return isolated_endpoints