我用Shapely创建了一个圆,并想用LineString将其拆分为两个
我创建了一个圆,如下所示
from functools import partial
import pyproj
from shapely import geometry
from shapely.geometry import Point, Polygon, shape, MultiPoint, LineString, mapping
from shapely.ops import transform, split
radius = 92600
lon = 54.08
lat = 17.05
local_azimuthal_projection = "+proj=aeqd +R=6371000 +units=m +lat_0={} +lon_0={}".format(
lat, lon
)
wgs84_to_aeqd = partial(
pyproj.transform,
pyproj.Proj("+proj=longlat +datum=WGS84 +no_defs"),
pyproj.Proj(local_azimuthal_projection),
)
aeqd_to_wgs84 = partial(
pyproj.transform,
pyproj.Proj(local_azimuthal_projection),
pyproj.Proj("+proj=longlat +datum=WGS84 +no_defs"),
)
center = Point(float(lon), float(lat))
point_transformed = transform(wgs84_to_aeqd, center)
buffer = point_transformed.buffer(radius)
# Get the polygon with lat lon coordinates
circle_poly = transform(aeqd_to_wgs84, buffer)
对于线拆分器,我有以下内容:
splitter = LingString([Point(54.79,16.90), Point(53.56,16.65)])
现在我想看到两个分割形状,所以我使用了分割函数
result = split(circle_poly, splitter)
但是,这只会产生相同的圆,而不是两个形状。 在结束时,我想使用分割的一部分,以形成另一个形状
要分割圆或多边形,可以对另一个多边形使用空间
difference
操作。Shapely不允许使用line
来执行此操作See document:
在本例中,您可以构建两个以
line
作为公共边的多边形。 确保两个多边形一起足够大,以覆盖要拆分的整个多边形。然后你用这个多边形来做这个工作如果希望从
difference
操作中获得粗略的结果, 您可以通过buffer
操作将直线转换为细长多边形,并使用它对于第二种方法,以下是相关代码:
结果是一个多多边形几何体对象
相关问题 更多 >
编程相关推荐