测试aoi坐标:
116.527712,39.924304;116.527123,39.924353;116.52707,39.923985;116.527685,39.92397;116.527712,39.924304
如图所示是一个有效的坐标,使用python代码判断是否有效:
代码:
from shapely.geometry import Polygon
# 假设这是一个电子围栏的坐标点
aoi="116.527712,39.924304;116.527123,39.924353;116.52707,39.923985;116.527685,39.92397;116.527712,39.924304"
points=[tuple(x.split(",")) for x in aoi.split(";")]
# 创建一个多边形
try:
poly = Polygon(points)
is_valid = poly.is_valid
if is_valid:
print("电子围栏有效")
else:
print("电子围栏无效")
except Exception as e:
print(f"创建多边形时发生错误: {e}")
运行输出结果: