def test_image_matrix(station_names): data = get_image_matrix() fc = FeatureCollection() for n in station_names: x, y = get_xy(n) fc.add_polygon(rbs.get_poly(x, y), dict(weight=data[x][y], name=n)) # So that scale is from 0 to 1 fc.add_polygon(rbs.get_poly(100, 100), dict(weight=0)) fc.dump('tmp1.geojson')
def draw_routing(filename, dir): fc = FeatureCollection() routing = pickle.load(open(filename))['routing'] stations = map(get_xy, sio.loadmat(MAT_FILE)['stations']) for row, (sx, sy) in zip(routing, stations): total = 0 for rate, (ex, ey) in zip(row, stations): dx, dy = ex - sx, ey - sy if dx > 0: total += rate * dx / np.sqrt(dx**2 + dy**2) fc.add_polygon(rbs.get_poly(sx, sy), {'weight': total}) fc.dump('routing.geojson')
def draw_rates(filename): fc = FeatureCollection() rates = pickle.load(open(filename))['rates'] for weight, station in zip(rates, sio.loadmat(MAT_FILE)['stations']): fc.add_polygon(rbs.get_poly(*get_xy(station)), {'weight': weight}) fc.dump('rates.geojson')