首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有可能对佛叶产生启示吗?

有可能对佛叶产生启示吗?
EN

Stack Overflow用户
提问于 2022-02-14 18:04:34
回答 1查看 197关注 0票数 0

我在网上的图片上看到,folium在地图上生成了一种启示录形式,我试着手工创建,但每点都不可行,有什么办法吗?叶状叶

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-15 04:14:47

是的,通过使用folium的多边形(和其他一些东西)

我复制了这个回答来构造多边形。

代码语言:javascript
复制
import math
from shapely.geometry import Point
from shapely.affinity import scale, rotate

#input parameters
A = Point(-95.5, 41.25)
B = Point(-96.5, 41.25)
R = .25

d = A.distance(B)

#first, rotate B to B' around A so that |AB'| = |AB| and B'.y = A.y
#and then take S as midpoint of AB'
S = Point(A.x + d/2, A.y)

#alpha represents the angle of this rotation
alpha = math.atan2(B.y - A.y, B.x - A.x)

#create a circle with center at S passing through A and B'
C = S.buffer(d/2)

#rescale this circle in y-direction so that the corresponding
#axis is R units long
C = scale(C, 1, R/(d/2))

#rotate the ellipse obtained in previous step around A into the
#original position (positive angles represent counter-clockwise rotation)
C = rotate(C, alpha, origin = A, use_radians = True)

其中C是一个形状多边形

代码语言:javascript
复制
print(type(C))
<class 'shapely.geometry.polygon.Polygon'>

我把坐标从X,Y翻转到Y,X,使之变得友好

folium_poly = [[y,x] for x,y in C.exterior.coords]

剩下的都是叶

代码语言:javascript
复制
import folium

m = folium.Map([C.centroid.y, C.centroid.x])
folium.Polygon(folium_poly).add_to(m)
m

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71116313

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档