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

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

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

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

  1. import math
  2. import os
  3. cir1 = []
  4. cir2 = []
  5. cir3 = []
  6. r1 = 80
  7. r2 = 100
  8. r3 = 120
  9. for theta in range(0, 360, 10):
  10. x1 = r1 * math.cos(math.radians(theta))
  11. y1 = r1 * math.sin(math.radians(theta))
  12. cir1.append((x1, y1))
  13. x2 = r2 * math.cos(math.radians(theta))
  14. y2 = r2 * math.sin(math.radians(theta))
  15. cir2.append((x2, y2))
  16. x3 = r3 * math.cos(math.radians(theta))
  17. y3 = r3 * math.sin(math.radians(theta))
  18. cir3.append((x3, y3))
  19. cir1.append(cir1[0])
  20. cir2.append(cir2[0])
  21. cir3.append(cir3[0])
  22. inner = []
  23. outer = []
  24. for i in range(36):
  25. 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]))
  26. 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]))
  27. print("内环坐标段:")
  28. for pts in inner:
  29. print("(%f, %f), (%f, %f), (%f, %f), (%f, %f)" % pts)
  30. print("外环坐标段:")
  31. for pts in outer:
  32. 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.

  1. import math
  2. import os
  3. cir1 = []
  4. cir2 = []
  5. cir3 = []
  6. r1 = 80
  7. r2 = 100
  8. r3 = 120
  9. for theta in range(0,360,10):
  10. x1 = r1 * math.cos( math.radians( theta ) )
  11. y1 = r1 * math.sin( math.radians( theta ) )
  12. cir1.append( (x1, y1) )
  13. x2 = r2 * math.cos( math.radians( theta ) )
  14. y2 = r2 * math.sin( math.radians( theta ) )
  15. cir2.append( (x2, y2) )
  16. x3 = r3 * math.cos( math.radians( theta ) )
  17. y3 = r3 * math.sin( math.radians( theta ) )
  18. cir3.append( (x3, y3) )
  19. cir1.append(cir1[0])
  20. cir2.append(cir2[0])
  21. cir3.append(cir3[0])
  22. inner = []
  23. outer = []
  24. for i in range(36):
  25. 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] ))
  26. 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] ))
  27. print( "Coords of innter ring segments:" )
  28. for pts in inner:
  29. print( "(%f,%f), (%f,%f), (%f,%f), (%f,%f)" % pts )
  30. print( "Coords of outer ring segments:" )
  31. for pts in outer:
  32. print( "(%f,%f), (%f,%f), (%f,%f), (%f,%f)" % pts )

Output:

  1. Coords of innter ring segments:
  2. (80.000000,0.000000), (100.000000,0.000000), (98.480775,17.364818), (78.784620,13.891854)
  3. (78.784620,13.891854), (98.480775,17.364818), (93.969262,34.202014), (75.175410,27.361611)
  4. (75.175410,27.361611), (93.969262,34.202014), (86.602540,50.000000), (69.282032,40.000000)
  5. (69.282032,40.000000), (86.602540,50.000000), (76.604444,64.278761), (61.283555,51.423009)
  6. (61.283555,51.423009), (76.604444,64.278761), (64.278761,76.604444), (51.423009,61.283555)
  7. (51.423009,61.283555), (64.278761,76.604444), (50.000000,86.602540), (40.000000,69.282032)
  8. (40.000000,69.282032), (50.000000,86.602540), (34.202014,93.969262), (27.361611,75.175410)
  9. (27.361611,75.175410), (34.202014,93.969262), (17.364818,98.480775), (13.891854,78.784620)
  10. (13.891854,78.784620), (17.364818,98.480775), (0.000000,100.000000), (0.000000,80.000000)
  11. (0.000000,80.000000), (0.000000,100.000000), (-17.364818,98.480775), (-13.891854,78.784620)
  12. (-13.891854,78.784620), (-17.364818,98.480775), (-34.202014,93.969262), (-27.361611,75.175410)
  13. (-27.361611,75.175410), (-34.202014,93.969262), (-50.000000,86.602540), (-40.000000,69.282032)
  14. (-40.000000,69.282032), (-50.000000,86.602540), (-64.278761,76.604444), (-51.423009,61.283555)
  15. (-51.423009,61.283555), (-64.278761,76.604444), (-76.604444,64.278761), (-61.283555,51.423009)
  16. (-61.283555,51.423009), (-76.604444,64.278761), (-86.602540,50.000000), (-69.282032,40.000000)
  17. (-69.282032,40.000000), (-86.602540,50.000000), (-93.969262,34.202014), (-75.175410,27.361611)
  18. (-75.175410,27.361611), (-93.969262,34.202014), (-98.480775,17.364818), (-78.784620,13.891854)
  19. (-78.784620,13.891854), (-98.480775,17.364818), (-100.000000,0.000000), (-80.000000,0.000000)
  20. (-80.000000,0.000000), (-100.000000,0.000000), (-98.480775,-17.364818), (-78.784620,-13.891854)
  21. (-78.784620,-13.891854), (-98.480775,-17.364818), (-93.969262,-34.202014), (-75.175410,-27.361611)
  22. (-75.175410,-27.361611), (-93.969262,-34.202014), (-86.602540,-50.000000), (-69.282032,-40.000000)
  23. (-69.282032,-40.000000), (-86.602540,-50.000000), (-76.604444,-64.278761), (-61.283555,-51.423009)
  24. (-61.283555,-51.423009), (-76.604444,-64.278761), (-64.278761,-76.604444), (-51.423009,-61.283555)
  25. (-51.423009,-61.283555), (-64.278761,-76.604444), (-50.000000,-86.602540), (-40.000000,-69.282032)
  26. (-40.000000,-69.282032), (-50.000000,-86.602540), (-34.202014,-93.969262), (-27.361611,-75.175410)
  27. (-27.361611,-75.175410), (-34.202014,-93.969262), (-17.364818,-98.480775), (-13.891854,-78.784620)
  28. (-13.891854,-78.784620), (-17.364818,-98.480775), (-0.000000,-100.000000), (-0.000000,-80.000000)
  29. (-0.000000,-80.000000), (-0.000000,-100.000000), (17.364818,-98.480775), (13.891854,-78.784620)
  30. (13.891854,-78.784620), (17.364818,-98.480775), (34.202014,-93.969262), (27.361611,-75.175410)
  31. (27.361611,-75.175410), (34.202014,-93.969262), (50.000000,-86.602540), (40.000000,-69.282032)
  32. (40.000000,-69.282032), (50.000000,-86.602540), (64.278761,-76.604444), (51.423009,-61.283555)
  33. (51.423009,-61.283555), (64.278761,-76.604444), (76.604444,-64.278761), (61.283555,-51.423009)
  34. (61.283555,-51.423009), (76.604444,-64.278761), (86.602540,-50.000000), (69.282032,-40.000000)
  35. (69.282032,-40.000000), (86.602540,-50.000000), (93.969262,-34.202014), (75.175410,-27.361611)
  36. (75.175410,-27.361611), (93.969262,-34.202014), (98.480775,-17.364818), (78.784620,-13.891854)
  37. (78.784620,-13.891854), (98.480775,-17.364818), (100.000000,0.000000), (80.000000,0.000000)
  38. Coords of outer ring segments:
  39. (100.000000,0.000000), (120.000000,0.000000), (118.176930,20.837781), (98.480775,17.364818)
  40. (98.480775,17.364818), (118.176930,20.837781), (112.763114,41.042417), (93.969262,34.202014)
  41. (93.969262,34.202014), (112.763114,41.042417), (103.923048,60.000000), (86.602540,50.000000)
  42. (86.602540,50.000000), (103.923048,60.000000), (91.925333,77.134513), (76.604444,64.278761)
  43. (76.604444,64.278761), (91.925333,77.134513), (77.134513,91.925333), (64.278761,76.604444)
  44. (64.278761,76.604444), (77.134513,91.925333), (60.000000,103.923048), (50.000000,86.602540)
  45. (50.000000,86.602540), (60.000000,103.923048), (41.042417,112.763114), (34.202014,93.969262)
  46. (34.202014,93.969262), (41.042417,112.763114), (20.837781,118.176930), (17.364818,98.480775)
  47. (17.364818,98.480775), (20.837781,118.176930), (0.000000,120.000000), (0.000000,100.000000)
  48. (0.000000,100.000000), (0.000000,120.000000), (-20.837781,118.176930), (-17.364818,98.480775)
  49. (-17.364818,98.480775), (-20.837781,118.176930), (-41.042417,112.763114), (-34.202014,93.969262)
  50. (-34.202014,93.969262), (-41.042417,112.763114), (-60.000000,103.923048), (-50.000000,86.602540)
  51. (-50.000000,86.602540), (-60.000000,103.923048), (-77.134513,91.925333), (-64.278761,76.604444)
  52. (-64.278761,76.604444), (-77.134513,91.925333), (-91.925333,77.134513), (-76.604444,64.278761)
  53. (-76.604444,64.278761), (-91.925333,77.134513), (-103.923048,60.000000), (-86.602540,50.000000)
  54. (-86.602540,50.000000), (-103.923048,60.000000), (-112.763114,41.042417), (-93.969262,34.202014)
  55. (-93.969262,34.202014), (-112.763114,41.042417), (-118.176930,20.837781), (-98.480775,17.364818)
  56. (-98.480775,17.364818), (-118.176930,20.837781), (-120.000000,0.000000), (-100.000000,0.000000)
  57. (-100.000000,0.000000), (-120.000000,0.000000), (-118.176930,-20.837781), (-98.480775,-17.364818)
  58. (-98.480775,-17.364818), (-118.176930,-20.837781), (-112.763114,-41.042417), (-93.969262,-34.202014)
  59. (-93.969262,-34.202014), (-112.763114,-41.042417), (-103.923048,-60.000000), (-86.602540,-50.000000)
  60. (-86.602540,-50.000000), (-103.923048,-60.000000), (-91.925333,-77.134513), (-76.604444,-64.278761)
  61. (-76.604444,-64.278761), (-91.925333,-77.134513), (-77.134513,-91.925333), (-64.278761,-76.604444)
  62. (-64.278761,-76.604444), (-77.134513,-91.925333), (-60.000000,-103.923048), (-50.000000,-86.602540)
  63. (-50.000000,-86.602540), (-60.000000,-103.923048), (-41.042417,-112.763114), (-34.202014,-93.969262)
  64. (-34.202014,-93.969262), (-41.042417,-112.763114), (-20.837781,-118.176930), (-17.364818,-98.480775)
  65. (-17.364818,-98.480775), (-20.837781,-118.176930), (-0.000000,-120.000000), (-0.000000,-100.000000)
  66. (-0.000000,-100.000000), (-0.000000,-120.000000), (20.837781,-118.176930), (17.364818,-98.480775)
  67. (17.364818,-98.480775), (20.837781,-118.176930), (41.042417,-112.763114), (34.202014,-93.969262)
  68. (34.202014,-93.969262), (41.042417,-112.763114), (60.000000,-103.923048), (50.000000,-86.602540)
  69. (50.000000,-86.602540), (60.000000,-103.923048), (77.134513,-91.925333), (64.278761,-76.604444)
  70. (64.278761,-76.604444), (77.134513,-91.925333), (91.925333,-77.134513), (76.604444,-64.278761)
  71. (76.604444,-64.278761), (91.925333,-77.134513), (103.923048,-60.000000), (86.602540,-50.000000)
  72. (86.602540,-50.000000), (103.923048,-60.000000), (112.763114,-41.042417), (93.969262,-34.202014)
  73. (93.969262,-34.202014), (112.763114,-41.042417), (118.176930,-20.837781), (98.480775,-17.364818)
  74. (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:

确定