python - 具有数据集点的 Ramer-Douglas-Peucker 算法
问题描述
在rdp算法的实现中:
from rdp import rdp
rdp([[1, 1], [2, 2], [3, 3], [4, 4]])
这些点是硬编码的。
我有一个数据集,我想从每个点读取 lon、lat,然后运行算法。
Python代码:
#returns the lon/lat
def load_data_from_file():
# load the point data
df = pd.read_csv('/home/repos/master/testdat.csv')
coordinates = df.as_matrix(columns=['LON', 'LAT'])
return coordinates
if __name__ == "__main__":
coordinates_of_file = load_data_from_file()
print " \n Initial coordinates pairs:", number_of_initial_points(coordinates_of_file),"\n"
number_of_pairs = number_of_initial_points(coordinates_of_file)
如果我执行一个循环来收集点的纬度/经度来执行算法,那么该算法适用于每一对而不是所有对。
for i in range((number_of_pairs)):
print "\n rdp (Insight Lab) results: ", rdp([coordinates_of_file[i]],
epsilon=0.05), "\n"
我想知道如何才能为数据集中的所有点运行算法。
解决方案
推荐阅读
- visual-studio - Visual Studio 设计/评估/项目加载 MSBuild 条件
- regex - 在Python中提取带有日期的字符串
- node.js - 连接本地网络上的设备
- node.js - 从 MemoryStorage 更改为 Azure Blob 存储后如何改进我的机器人的响应时间
- windows - Nagios 插件在 Windows PowerShell 中检查 md5 目录总和
- angular - 如何为 Angular + NativeScript 项目启动永久服务?
- c# - QueryString 与正文中的 ASP.NET 日期时间序列化
- angular - 跨多个项目共享一个角度库
- gosu - 数据库 bean 版本冲突 -(工作队列中的进程记录 Guidewire
- python - Ftplib 下载 zip 文件尝试失败([Errno 13] Permission denied: 'C:\\Users\\kbrab\\Desktop\\2019\\test.zip)