import logging logging.basicConfig(level=logging.INFO, format='%(asctime)s-%(filename)s[line:%(lineno)d]-%(levelname)s:%(message)s', datefmt='%Y-%m-%d %H:%M:%S') from geopy.distance import geodesic def stop2label(pnts, near=300): # 基于300m的半径对位置进行合并 # pnts [(lng,lat), (), *] res = [] pfun = lambda p1, p2: round(geodesic(p1[::-1], p2[::-1]).m, 1) count = 1 while pnts.__len__(): ipnt = pnts[0] flags = [pfun(ipnt, _) < near for _ in pnts] for idx, flag in enumerate(flags): if flag: res.append((pnts[idx], count)) logging.info((flags, len(pnts))) pnts = [pnts[_] for _, flag in enumerate(flags) if not flag] count += 1 return res
标签:-%,logging,经纬度,res,点聚类,flag,flags,简单,pnts From: https://www.cnblogs.com/ddzhen/p/17684038.html