Last active
November 23, 2015 21:10
-
-
Save brendancol/a17fa7e28104eca785ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from bokeh.models import Range1d | |
| from bokeh.models import WMTSTileSource | |
| from bokeh.models import ImageSource | |
| from bokeh.plotting import figure | |
| from bokeh.plotting import show | |
| from bokeh.plotting import output_file | |
| output_file('datashader_example.html') | |
| tile_options = {} | |
| tile_options['url'] = 'http://tile.stamen.com/toner/{Z}/{X}/{Y}.png' | |
| tile_source = WMTSTileSource(**tile_options) | |
| # create label tile source ----------- | |
| tile_label_options = {} | |
| tile_label_options['url'] = 'http://tile.stamen.com/toner-labels/{Z}/{X}/{Y}.png' | |
| tile_label_source = WMTSTileSource(**tile_label_options) | |
| # create datashader image source ----------- | |
| shader_url_vars = {} | |
| shader_url_vars['host'] = 'localhost' | |
| shader_url_vars['port'] = 5000 | |
| shader_url_vars['layer_name'] = 'CENSUS_SYN_PEOPLE' | |
| shader_url_vars['arl'] = "agg.colorize({'w': 'blue', 'h': 'orange', 'a': 'red', 'o': 'saddlebrown', 'b': 'green'})" | |
| service_url = 'http://{host}:{port}/{layer_name}?' | |
| service_url += 'height={HEIGHT}&' | |
| service_url += 'width={WIDTH}&' | |
| service_url += 'arl={arl}&' | |
| service_url += 'select={XMIN};{YMIN};{XMAX};{YMAX};' | |
| dynamic_image_options = {} | |
| dynamic_image_options['url'] = service_url | |
| dynamic_image_options['extra_url_vars'] = shader_url_vars | |
| dynamic_image_source = ImageSource(**dynamic_image_options) | |
| # create plot ----------- | |
| fig = figure(tools='wheel_zoom,pan', title="DATASHADER") | |
| fig.x_range = Range1d(start=-12500000, end=-9000000) | |
| fig.y_range = Range1d(start=4000000, end=5100000) | |
| fig.plot_height = 700 | |
| fig.plot_width = 700 | |
| fig.min_border = 0 | |
| fig.axis.visible = False | |
| fig.add_tile(tile_source) | |
| fig.add_dynamic_image(dynamic_image_source) | |
| fig.add_tile(tile_label_source, **dict(render_parents=False)) | |
| show(fig) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment