提取线字符串和圆形多边形几何图形相交时的阴影区域坐标如何?

huangapple go评论75阅读模式
英文:

How to extract the coordinate of the shaded region when LineString and circular Polygon geometries intersects?

问题

I have geometries, as shown in the figure.
三个圆形多边形几何体(circle1、circle2 和 circle3)和十九个线串(line0、line1、...、line18)。
我想提取灰色阴影区域的坐标(位于 circle1 和 circle 之间的区域,已被穿过的线串均等分)。在图中,我只阴影了三个区域,但我希望分别提取所有类似的区域坐标作为列表。

如何实现?如果解决方案能够使用 geopandas 和 shapely 的功能,那就太好了。
我尝试在线串和多边形之间进行插值,但毫无用处。你能帮助我吗?
提取线字符串和圆形多边形几何图形相交时的阴影区域坐标如何?

英文:

I have geometries, as shown in the figure.
three circular Polygon geometries (circle1,circle2 and circle3) and nineteen LineStrimgs (line0,line1,...,line18).
I want to extract the coordinates of the grey-shaded region (area between circle1 and circle, which has been equally divided by the passing line strings) in the figure. Here I only shaded three areas, but I want to extract the coordinates of all the similar regions individually as a list.

How can I do that? If the solution could use the functionalities of geopandas and shapely, it would be great.
I tried to interpolate the method between the Linestring and polygons, but there was no use at all. Could you help me?
提取线字符串和圆形多边形几何图形相交时的阴影区域坐标如何?

答案1

得分: 1

这是您要翻译的代码的一部分:

import math
import os

cir1 = []
cir2 = []
cir3 = []
r1 = 80
r2 = 100
r3 = 120

for theta in range(0, 360, 10):
    x1 = r1 * math.cos(math.radians(theta))
    y1 = r1 * math.sin(math.radians(theta))
    cir1.append((x1, y1))
    x2 = r2 * math.cos(math.radians(theta))
    y2 = r2 * math.sin(math.radians(theta))
    cir2.append((x2, y2))
    x3 = r3 * math.cos(math.radians(theta))
    y3 = r3 * math.sin(math.radians(theta))
    cir3.append((x3, y3))

cir1.append(cir1[0])
cir2.append(cir2[0])
cir3.append(cir3[0])

inner = []
outer = []
for i in range(36):
    inner.append((cir1[i][0], cir1[i][1], cir2[i][0], cir2[i][1], cir2[i + 1][0], cir2[i + 1][1], cir1[i + 1][0], cir1[i + 1][1]))
    outer.append((cir2[i][0], cir2[i][1], cir3[i][0], cir3[i][1], cir3[i + 1][0], cir3[i + 1][1], cir2[i + 1][0], cir2[i + 1][1]))

print("内环坐标段:")
for pts in inner:
    print("(%f, %f), (%f, %f), (%f, %f), (%f, %f)" % pts)

print("外环坐标段:")
for pts in outer:
    print("(%f, %f), (%f, %f), (%f, %f), (%f, %f)" % pts)

这是您要翻译的代码的一部分。

英文:

This does what you ask. Note that I have hardcoded the 3 radii, and I have not adjusted for the center point.

import math
import os


cir1 = []
cir2 = []
cir3 = []
r1 = 80
r2 = 100
r3 = 120

for theta in range(0,360,10):
    x1 = r1 * math.cos( math.radians( theta ) )
    y1 = r1 * math.sin( math.radians( theta ) )
    cir1.append( (x1, y1) )
    x2 = r2 * math.cos( math.radians( theta ) )
    y2 = r2 * math.sin( math.radians( theta ) )
    cir2.append( (x2, y2) )
    x3 = r3 * math.cos( math.radians( theta ) )
    y3 = r3 * math.sin( math.radians( theta ) )
    cir3.append( (x3, y3) )

cir1.append(cir1[0])
cir2.append(cir2[0])
cir3.append(cir3[0])

inner = []
outer = []
for i in range(36):
    inner.append( (cir1[i][0],cir1[i][1], cir2[i][0],cir2[i][1], cir2[i+1][0],cir2[i+1][1], cir1[i+1][0],cir1[i+1][1] ))
    outer.append( (cir2[i][0],cir2[i][1], cir3[i][0],cir3[i][1], cir3[i+1][0],cir3[i+1][1], cir2[i+1][0],cir2[i+1][1] ))

print( "Coords of innter ring segments:" )
for pts in inner:
    print( "(%f,%f), (%f,%f), (%f,%f), (%f,%f)" % pts )

print( "Coords of outer ring segments:" )
for pts in outer:
    print( "(%f,%f), (%f,%f), (%f,%f), (%f,%f)" % pts )

Output:

Coords of innter ring segments:
(80.000000,0.000000), (100.000000,0.000000), (98.480775,17.364818), (78.784620,13.891854)
(78.784620,13.891854), (98.480775,17.364818), (93.969262,34.202014), (75.175410,27.361611)
(75.175410,27.361611), (93.969262,34.202014), (86.602540,50.000000), (69.282032,40.000000)
(69.282032,40.000000), (86.602540,50.000000), (76.604444,64.278761), (61.283555,51.423009)
(61.283555,51.423009), (76.604444,64.278761), (64.278761,76.604444), (51.423009,61.283555)
(51.423009,61.283555), (64.278761,76.604444), (50.000000,86.602540), (40.000000,69.282032)
(40.000000,69.282032), (50.000000,86.602540), (34.202014,93.969262), (27.361611,75.175410)
(27.361611,75.175410), (34.202014,93.969262), (17.364818,98.480775), (13.891854,78.784620)
(13.891854,78.784620), (17.364818,98.480775), (0.000000,100.000000), (0.000000,80.000000)
(0.000000,80.000000), (0.000000,100.000000), (-17.364818,98.480775), (-13.891854,78.784620)
(-13.891854,78.784620), (-17.364818,98.480775), (-34.202014,93.969262), (-27.361611,75.175410)
(-27.361611,75.175410), (-34.202014,93.969262), (-50.000000,86.602540), (-40.000000,69.282032)
(-40.000000,69.282032), (-50.000000,86.602540), (-64.278761,76.604444), (-51.423009,61.283555)
(-51.423009,61.283555), (-64.278761,76.604444), (-76.604444,64.278761), (-61.283555,51.423009)
(-61.283555,51.423009), (-76.604444,64.278761), (-86.602540,50.000000), (-69.282032,40.000000)
(-69.282032,40.000000), (-86.602540,50.000000), (-93.969262,34.202014), (-75.175410,27.361611)
(-75.175410,27.361611), (-93.969262,34.202014), (-98.480775,17.364818), (-78.784620,13.891854)
(-78.784620,13.891854), (-98.480775,17.364818), (-100.000000,0.000000), (-80.000000,0.000000)
(-80.000000,0.000000), (-100.000000,0.000000), (-98.480775,-17.364818), (-78.784620,-13.891854)
(-78.784620,-13.891854), (-98.480775,-17.364818), (-93.969262,-34.202014), (-75.175410,-27.361611)
(-75.175410,-27.361611), (-93.969262,-34.202014), (-86.602540,-50.000000), (-69.282032,-40.000000)
(-69.282032,-40.000000), (-86.602540,-50.000000), (-76.604444,-64.278761), (-61.283555,-51.423009)
(-61.283555,-51.423009), (-76.604444,-64.278761), (-64.278761,-76.604444), (-51.423009,-61.283555)
(-51.423009,-61.283555), (-64.278761,-76.604444), (-50.000000,-86.602540), (-40.000000,-69.282032)
(-40.000000,-69.282032), (-50.000000,-86.602540), (-34.202014,-93.969262), (-27.361611,-75.175410)
(-27.361611,-75.175410), (-34.202014,-93.969262), (-17.364818,-98.480775), (-13.891854,-78.784620)
(-13.891854,-78.784620), (-17.364818,-98.480775), (-0.000000,-100.000000), (-0.000000,-80.000000)
(-0.000000,-80.000000), (-0.000000,-100.000000), (17.364818,-98.480775), (13.891854,-78.784620)
(13.891854,-78.784620), (17.364818,-98.480775), (34.202014,-93.969262), (27.361611,-75.175410)
(27.361611,-75.175410), (34.202014,-93.969262), (50.000000,-86.602540), (40.000000,-69.282032)
(40.000000,-69.282032), (50.000000,-86.602540), (64.278761,-76.604444), (51.423009,-61.283555)
(51.423009,-61.283555), (64.278761,-76.604444), (76.604444,-64.278761), (61.283555,-51.423009)
(61.283555,-51.423009), (76.604444,-64.278761), (86.602540,-50.000000), (69.282032,-40.000000)
(69.282032,-40.000000), (86.602540,-50.000000), (93.969262,-34.202014), (75.175410,-27.361611)
(75.175410,-27.361611), (93.969262,-34.202014), (98.480775,-17.364818), (78.784620,-13.891854)
(78.784620,-13.891854), (98.480775,-17.364818), (100.000000,0.000000), (80.000000,0.000000)
Coords of outer ring segments:
(100.000000,0.000000), (120.000000,0.000000), (118.176930,20.837781), (98.480775,17.364818)
(98.480775,17.364818), (118.176930,20.837781), (112.763114,41.042417), (93.969262,34.202014)
(93.969262,34.202014), (112.763114,41.042417), (103.923048,60.000000), (86.602540,50.000000)
(86.602540,50.000000), (103.923048,60.000000), (91.925333,77.134513), (76.604444,64.278761)
(76.604444,64.278761), (91.925333,77.134513), (77.134513,91.925333), (64.278761,76.604444)
(64.278761,76.604444), (77.134513,91.925333), (60.000000,103.923048), (50.000000,86.602540)
(50.000000,86.602540), (60.000000,103.923048), (41.042417,112.763114), (34.202014,93.969262)
(34.202014,93.969262), (41.042417,112.763114), (20.837781,118.176930), (17.364818,98.480775)
(17.364818,98.480775), (20.837781,118.176930), (0.000000,120.000000), (0.000000,100.000000)
(0.000000,100.000000), (0.000000,120.000000), (-20.837781,118.176930), (-17.364818,98.480775)
(-17.364818,98.480775), (-20.837781,118.176930), (-41.042417,112.763114), (-34.202014,93.969262)
(-34.202014,93.969262), (-41.042417,112.763114), (-60.000000,103.923048), (-50.000000,86.602540)
(-50.000000,86.602540), (-60.000000,103.923048), (-77.134513,91.925333), (-64.278761,76.604444)
(-64.278761,76.604444), (-77.134513,91.925333), (-91.925333,77.134513), (-76.604444,64.278761)
(-76.604444,64.278761), (-91.925333,77.134513), (-103.923048,60.000000), (-86.602540,50.000000)
(-86.602540,50.000000), (-103.923048,60.000000), (-112.763114,41.042417), (-93.969262,34.202014)
(-93.969262,34.202014), (-112.763114,41.042417), (-118.176930,20.837781), (-98.480775,17.364818)
(-98.480775,17.364818), (-118.176930,20.837781), (-120.000000,0.000000), (-100.000000,0.000000)
(-100.000000,0.000000), (-120.000000,0.000000), (-118.176930,-20.837781), (-98.480775,-17.364818)
(-98.480775,-17.364818), (-118.176930,-20.837781), (-112.763114,-41.042417), (-93.969262,-34.202014)
(-93.969262,-34.202014), (-112.763114,-41.042417), (-103.923048,-60.000000), (-86.602540,-50.000000)
(-86.602540,-50.000000), (-103.923048,-60.000000), (-91.925333,-77.134513), (-76.604444,-64.278761)
(-76.604444,-64.278761), (-91.925333,-77.134513), (-77.134513,-91.925333), (-64.278761,-76.604444)
(-64.278761,-76.604444), (-77.134513,-91.925333), (-60.000000,-103.923048), (-50.000000,-86.602540)
(-50.000000,-86.602540), (-60.000000,-103.923048), (-41.042417,-112.763114), (-34.202014,-93.969262)
(-34.202014,-93.969262), (-41.042417,-112.763114), (-20.837781,-118.176930), (-17.364818,-98.480775)
(-17.364818,-98.480775), (-20.837781,-118.176930), (-0.000000,-120.000000), (-0.000000,-100.000000)
(-0.000000,-100.000000), (-0.000000,-120.000000), (20.837781,-118.176930), (17.364818,-98.480775)
(17.364818,-98.480775), (20.837781,-118.176930), (41.042417,-112.763114), (34.202014,-93.969262)
(34.202014,-93.969262), (41.042417,-112.763114), (60.000000,-103.923048), (50.000000,-86.602540)
(50.000000,-86.602540), (60.000000,-103.923048), (77.134513,-91.925333), (64.278761,-76.604444)
(64.278761,-76.604444), (77.134513,-91.925333), (91.925333,-77.134513), (76.604444,-64.278761)
(76.604444,-64.278761), (91.925333,-77.134513), (103.923048,-60.000000), (86.602540,-50.000000)
(86.602540,-50.000000), (103.923048,-60.000000), (112.763114,-41.042417), (93.969262,-34.202014)
(93.969262,-34.202014), (112.763114,-41.042417), (118.176930,-20.837781), (98.480775,-17.364818)
(98.480775,-17.364818), (118.176930,-20.837781), (120.000000,0.000000), (100.000000,0.000000)

huangapple
  • 本文由 发表于 2023年5月23日 01:51:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76308776.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定