return contents def bikable_zone(unit): if 'original_value' not in unit or unit.get('original_value') is None: return False return unit.get('original_value') > 1.5 and unit.get('bike_val') < 25 renderer = DefaultRenderer(center=home, zoom=12, opacity=0.5, label=make_label, color_scale=custom_color_scale) h_map = HeatMap(home, geo_json, filename='bike_vs_ubahn', square_size=800, num_threads=100, load_intermediate_results=True) h_map.generate(calc_time) h_map.normalize(normalize_log2_scale) h_map.generate_polygon(bikable_zone, color='#0012b3', opacity=0.6, weight=5, dash_array=[1, 6]) h_map.render( renderer, before_saving=lambda r, _: r.add_circle(home, color='#0012b3', radius=20))
# The extractor gets the data toilet_extr = ToiletExtractor( './data/oeffentlichetoilettenmuenchen2016-06-28.csv', 'latitude', 'longitude') # The renderer deals with visual aspects of the map renderer = DefaultRenderer(center=marienplatz, zoom=12, opacity=0.35, color_scale=custom_color_scale, tiles='cartodbdark_matter') # Create a new heatmap h_map = HeatMap(None, geo_json, filename='toilet', square_size=500, num_threads=100, load_intermediate_results=True) h_map.generate(toilet_extr.get_value) h_map.normalize() # Generate the polygon areas within 1km of a public toilet h_map.generate_polygon(lambda v: v.get('lin_value', 999) < 1.0, dash_array=[5, 5], color='#0ef', opacity=0.5, weight=2) # Render and save h_map.render(renderer, before_saving=toilet_extr.add_markers)
with open('./geo/muenchen.json', 'r') as fp: geo_json = json.load(fp) def calc_time(pt1, pt2): """ Calculate the time to get somewhere by UBahn """ t_ubahn = mvg.average_time_between(pt1, pt2, datetime.now()) if not t_ubahn: return None value = int(t_ubahn / 60.0) # Since the value will be normalized, we save it also on a separate key to show it on the label return {'value': value, 'time': value} renderer = DefaultRenderer(center=home, zoom=12, color_scale=color, label=label) h_map = HeatMap(home, geo_json, square_size=250, filename='mvg', load_intermediate_results=True) h_map.generate(calc_time) # Normalize on a log2 scale h_map.normalize(lambda v, _1, _2: log2(v)) # Then again on a 0 to 1 range h_map.normalize() h_map.render(renderer)