Geodata: Disappearing glyphs, Save button not working and map out of frame

Hello everyone,

I’m new to Bokeh and I’m having some problems using it. I will try to describe my problems and purpose as complete as possible, but feel free to skip irrelevant parts of my post.

Purpose:

Plot roads and bridges in Bangladesh on a map, to give insight in the vulnerability of these roads and bridges.

How:

Plot roads as lines in the map and use width and color as metrics to indicate certain vulnerability indicators

Plot bridges as dots in the map and use size and color ~~

Progress:

At this point I’m exploring Bokeh’s functionalities. I have made different maps with using GMapPlot and Stamen map.

I found it difficult to work with coordinates in Stamen (I don’t have much knowledge of JSTOR), so I decided to use GMapPlot, since it handles coordinates more easily.

I started with plotting some random points in Bangladesh and that works

I wanted to plot a square around bangladesh and this doesn’t work.

At this point I have no clue what the problem could be, because I don’t get errors

Problems at this point:

  1. I want to plot 2 glyphs on the map (circles and lines), The points work, but the lines don’t
  2. If I add both lines and circles, the lines are not plotted
  3. If I comment out the circles, the lines glyph appears and then disappears again.
  4. The save button let’s me download a file, but the picture shows nothing.
  5. The map is plotted out of it’s frame (both with using chrome and edge browsers

Additional question:

  • Are there known disadvantages of using GMapPlot? Do you recommend me to use Stamen in combination with JSTOR?

I’m looking forward to receiving some feedback.

Regards,

Tim

Attachements:

  • Bokeh html file
  • Python code
  • Jupyter Notebook File
  • Below I also pasted the code I used

Python code (Python 3 and working in Jupyter notebooks 4.3.1)

from bokeh.io import output_file, show

from bokeh.models import (

GMapPlot, GMapOptions, ColumnDataSource, Circle, DataRange1d,

PanTool, WheelZoomTool, BoxSelectTool, SaveTool, )

from bokeh.models.glyphs import Segment

map_options = GMapOptions(lat=24, lng=90, map_type=“roadmap”, zoom=7)

plot = GMapPlot(

x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options

)

plot.title.text = “Bangladesh”

https://developers.google.com/maps/documentation/javascript/get-api-key

plot.api_key = “AIzaSyD27PG4tV85tftwwxSn-Rl2RVSoFqjxtVw”

Load in Bangladesh Data

source_lines = ColumnDataSource(

data = dict(

lon0=[88,88,92,92], #x

lon1=[88,92,92,88], #x

lat0=[20,26,20,20], #y

lat1=[26,26,26,20], #y

width=[2,4,6,8]))

source_points = ColumnDataSource(

data=dict(

lat = [20,26,20,26,23.81],

lon = [88,88,92,92,90.4],

size = [9,9,9,9,10],

info = [“a”,“b”,“c”,“d”,“Dhaka”]

)

)

circle = Circle(x=“lon”, y=“lat”, size=‘size’, fill_color=“blue”, fill_alpha=0.8, line_color=None)

plot.add_glyph(source_points, circle)

lines = Segment(x0=‘lon0’, y0=‘lat0’, x1=‘lon1’,

y1=‘lat1’, line_color=“red”, line_width=100)

plot.add_glyph(source_lines, lines)

plot.add_tools(PanTool(), WheelZoomTool(), SaveTool())

output_file(“gmap_plot.html”)

show(plot)

gmap_plot.html (37.3 KB)

Test map-2-clean-v6.ipynb (3.56 KB)

Hi,

The "out of frame" problem is due to some change on Google's end. However, this problem has recently been fixed in master and will be in the next release. It is also available in the latest dev builds.

The save button can only save what is on the HTML canvas currently which means it cannot work with GMaps, unfortunately (they render in a separate DOM element).

Regarding the other issue you mention, I think that was also recently fixed in master (there is a pile of GMap improvements and fixes going in the next release) but it's not possible to know for sure without code to run.

I think you will find GMap significantly improved when 0.12.5 is released. However, if "save" is a mandatory requirement for you, then I think for now your only option is the TileRenderer (e.g. Stamen) plots. If you have suggestions that would help with specifying coordinates, etc. please make feature requests on GitHub:

  https://github.com/bokeh/bokeh/issues

It's almost always better when feature development proceeds from concrete user use-cases so your input would be valuable.

Thanks,

Bryan

···

On Mar 11, 2017, at 17:39, Tim <[email protected]> wrote:

Hello everyone,

I'm new to Bokeh and I'm having some problems using it. I will try to describe my problems and purpose as complete as possible, but feel free to skip irrelevant parts of my post.

Purpose:
Plot roads and bridges in Bangladesh on a map, to give insight in the vulnerability of these roads and bridges.

How:
Plot roads as lines in the map and use width and color as metrics to indicate certain vulnerability indicators
Plot bridges as dots in the map and use size and color ~~

Progress:
At this point I'm exploring Bokeh's functionalities. I have made different maps with using GMapPlot and Stamen map.
I found it difficult to work with coordinates in Stamen (I don't have much knowledge of JSTOR), so I decided to use GMapPlot, since it handles coordinates more easily.

I started with plotting some random points in Bangladesh and that works
I wanted to plot a square around bangladesh and this doesn't work.
At this point I have no clue what the problem could be, because I don't get errors

Problems at this point:
  • I want to plot 2 glyphs on the map (circles and lines), The points work, but the lines don't
    • If I add both lines and circles, the lines are not plotted
    • If I comment out the circles, the lines glyph appears and then disappears again.
  • The save button let's me download a file, but the picture shows nothing.
  • The map is plotted out of it's frame (both with using chrome and edge browsers

Additional question:
- Are there known disadvantages of using GMapPlot? Do you recommend me to use Stamen in combination with JSTOR?

I'm looking forward to receiving some feedback.

Regards,
Tim

Attachements:
  • Bokeh html file
  • Python code
    • Jupyter Notebook File
    • Below I also pasted the code I used

Python code (Python 3 and working in Jupyter notebooks 4.3.1)

from bokeh.io import output_file, show
from bokeh.models import (
  GMapPlot, GMapOptions, ColumnDataSource, Circle, DataRange1d,
    PanTool, WheelZoomTool, BoxSelectTool, SaveTool, )
from bokeh.models.glyphs import Segment

map_options = GMapOptions(lat=24, lng=90, map_type="roadmap", zoom=7)

plot = GMapPlot(
    x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options
)
plot.title.text = "Bangladesh"

# https://developers.google.com/maps/documentation/javascript/get-api-key
plot.api_key = "AIzaSyD27PG4tV85tftwwxSn-Rl2RVSoFqjxtVw"

# Load in Bangladesh Data
source_lines = ColumnDataSource(
    data = dict(
    lon0=[88,88,92,92], #x
    lon1=[88,92,92,88], #x
    lat0=[20,26,20,20], #y
    lat1=[26,26,26,20], #y
    width=[2,4,6,8]))

source_points = ColumnDataSource(
    data=dict(
        lat = [20,26,20,26,23.81],
        lon = [88,88,92,92,90.4],
        size = [9,9,9,9,10],
        info = ["a","b","c","d","Dhaka"]
    )
)

# circle = Circle(x="lon", y="lat", size='size', fill_color="blue", fill_alpha=0.8, line_color=None)
# plot.add_glyph(source_points, circle)

lines = Segment(x0='lon0', y0='lat0', x1='lon1',
          y1='lat1', line_color="red", line_width=100)
plot.add_glyph(source_lines, lines)

plot.add_tools(PanTool(), WheelZoomTool(), SaveTool())
output_file("gmap_plot.html")
show(plot)

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/20416263-5221-4c3e-aab1-81e49681be3a%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
<gmap_plot.html><Test map-2-clean-v6.ipynb>

Hi Bryan,

Thank you for your reply. I decided to change my approach and I’m running into a new problem.

With this code, I’m able to plot an rectangle with 4 points and 4 lines.However, it doesn’t use Lat Lon inputs. How do I change my input coordinates to Lat Lon?

My code:
from bokeh.io import output_file, show

from bokeh.plotting import figure

from bokeh.tile_providers import STAMEN_TONER, STAMEN_TERRAIN, CARTODBPOSITRON

from bokeh.plotting import ColumnDataSource

from bokeh.models import HoverTool

from bokeh.models import WheelZoomTool, PanTool, SaveTool, ResetTool

source_lines = ColumnDataSource(

data = dict(

lon0=[88,88,92,92], #x

lon1=[88,92,92,88], #x

lat0=[20,26,20,20], #y

lat1=[26,26,26,20], #y

width=[2,4,6,8]))

source_circles = ColumnDataSource(

data = dict(

lat = [20,26,20,26],

lon = [88,88,92,92],

size = [5,2,3,7],

width = [“a”,“b”,“c”,“d”]

))

hover = HoverTool(

tooltips=[

(“index”,"$index"),

("(x,y)", “($lon,$lat)”),

(“size”, “@size”),

(“width”,"@width")

])

bound = 200 # meters

fig = figure(tools = [hover],x_range=(-bound, bound),

y_range=(-bound, bound))

fig.add_tools(WheelZoomTool(),PanTool(),SaveTool(), ResetTool())

fig.toolbar.active_scroll = WheelZoomTool()

fig.axis.visible = True

fig.segment(x0=‘lon0’, y0=‘lat0’, x1=‘lon1’,

y1=‘lat1’, color="#F4A582", line_width=‘width’, source=source_lines)

fig.circle(‘lon’,‘lat’, fill_color=‘red’, size = ‘size’, source=source_circles)

fig.axis.visible = True

fig.add_tile(CARTODBPOSITRON)

output_file(“Rectangle around Bangladesh.html”)

show(fig)

``

···

On Sunday, 12 March 2017 22:11:44 UTC+1, Bryan Van de ven wrote:

Hi,

The “out of frame” problem is due to some change on Google’s end. However, this problem has recently been fixed in master and will be in the next release. It is also available in the latest dev builds.

The save button can only save what is on the HTML canvas currently which means it cannot work with GMaps, unfortunately (they render in a separate DOM element).

Regarding the other issue you mention, I think that was also recently fixed in master (there is a pile of GMap improvements and fixes going in the next release) but it’s not possible to know for sure without code to run.

I think you will find GMap significantly improved when 0.12.5 is released. However, if “save” is a mandatory requirement for you, then I think for now your only option is the TileRenderer (e.g. Stamen) plots. If you have suggestions that would help with specifying coordinates, etc. please make feature requests on GitHub:

    [https://github.com/bokeh/bokeh/issues](https://github.com/bokeh/bokeh/issues)

It’s almost always better when feature development proceeds from concrete user use-cases so your input would be valuable.

Thanks,

Bryan

On Mar 11, 2017, at 17:39, Tim [email protected] wrote:

Hello everyone,

I’m new to Bokeh and I’m having some problems using it. I will try to describe my problems and purpose as complete as possible, but feel free to skip irrelevant parts of my post.

Purpose:

Plot roads and bridges in Bangladesh on a map, to give insight in the vulnerability of these roads and bridges.

How:

Plot roads as lines in the map and use width and color as metrics to indicate certain vulnerability indicators

Plot bridges as dots in the map and use size and color ~~

Progress:

At this point I’m exploring Bokeh’s functionalities. I have made different maps with using GMapPlot and Stamen map.

I found it difficult to work with coordinates in Stamen (I don’t have much knowledge of JSTOR), so I decided to use GMapPlot, since it handles coordinates more easily.

I started with plotting some random points in Bangladesh and that works

I wanted to plot a square around bangladesh and this doesn’t work.

At this point I have no clue what the problem could be, because I don’t get errors

Problems at this point:

    • I want to plot 2 glyphs on the map (circles and lines), The points work, but the lines don't
            • If I add both lines and circles, the lines are not plotted
            • If I comment out the circles, the lines glyph appears and then disappears again.
    • The save button let's me download a file, but the picture shows nothing.
    • The map is plotted out of it's frame (both with using chrome and edge browsers

Additional question:

  • Are there known disadvantages of using GMapPlot? Do you recommend me to use Stamen in combination with JSTOR?

I’m looking forward to receiving some feedback.

Regards,

Tim

Attachements:

    • Bokeh html file
    • Python code
            • Jupyter Notebook File
            • Below I also pasted the code I used

Python code (Python 3 and working in Jupyter notebooks 4.3.1)

from bokeh.io import output_file, show

from bokeh.models import (

GMapPlot, GMapOptions, ColumnDataSource, Circle, DataRange1d,

PanTool, WheelZoomTool, BoxSelectTool, SaveTool, )

from bokeh.models.glyphs import Segment

map_options = GMapOptions(lat=24, lng=90, map_type=“roadmap”, zoom=7)

plot = GMapPlot(

x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options

)

plot.title.text = “Bangladesh”

https://developers.google.com/maps/documentation/javascript/get-api-key

plot.api_key = “AIzaSyD27PG4tV85tftwwxSn-Rl2RVSoFqjxtVw”

Load in Bangladesh Data

source_lines = ColumnDataSource(

data = dict(
lon0=[88,88,92,92],  #x
lon1=[88,92,92,88],  #x
lat0=[20,26,20,20],  #y
lat1=[26,26,26,20],  #y
width=[2,4,6,8]))

source_points = ColumnDataSource(

data=dict(
    lat = [20,26,20,26,23.81],
    lon = [88,88,92,92,90.4],
    size = [9,9,9,9,10],
    info = ["a","b","c","d","Dhaka"]
)

)

circle = Circle(x=“lon”, y=“lat”, size=‘size’, fill_color=“blue”, fill_alpha=0.8, line_color=None)

plot.add_glyph(source_points, circle)

lines = Segment(x0=‘lon0’, y0=‘lat0’, x1=‘lon1’,

      y1='lat1', line_color="red", line_width=100)

plot.add_glyph(source_lines, lines)

plot.add_tools(PanTool(), WheelZoomTool(), SaveTool())

output_file(“gmap_plot.html”)

show(plot)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/20416263-5221-4c3e-aab1-81e49681be3a%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

<gmap_plot.html>

The coordinates used by the TileRenderer are web mercator coordinates. The most direct solution is probably simply to convert your lat/lon coordinates for the lines and circles, into web mercator, using any of the existing python libraries for computing map projections.

Alternatively, you could try adding an 'extra range' as decscribed here:

  http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#twin-axes

That example happens to also add a second axis for the extra range, but that's purely optional You could add an extra range just to drive glyphs from. I would note, however, that I cannot be certain this approach would work well when zoomed out. Bokeh tries to maintain the relative relationship between ranges across any panning and zooming, which works great for cartesian coordinates. I am not sure that will work across all scales once map projections are involved.

Thanks,

Bryan

···

On Mar 13, 2017, at 05:46, Tim <[email protected]> wrote:

Hi Bryan,

Thank you for your reply. I decided to change my approach and I'm running into a new problem.

With this code, I'm able to plot an rectangle with 4 points and 4 lines.However, it doesn't use Lat Lon inputs. How do I change my input coordinates to Lat Lon?

My code:
from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.tile_providers import STAMEN_TONER, STAMEN_TERRAIN, CARTODBPOSITRON
from bokeh.plotting import ColumnDataSource
from bokeh.models import HoverTool
from bokeh.models import WheelZoomTool, PanTool, SaveTool, ResetTool

source_lines = ColumnDataSource(
    data = dict(
    lon0=[88,88,92,92], #x
    lon1=[88,92,92,88], #x
    lat0=[20,26,20,20], #y
    lat1=[26,26,26,20], #y
    width=[2,4,6,8]))

source_circles = ColumnDataSource(
    data = dict(
    lat = [20,26,20,26],
    lon = [88,88,92,92],
    size = [5,2,3,7],
    width = ["a","b","c","d"]
    ))

hover = HoverTool(
    tooltips=[
    ("index","$index"),
    ("(x,y)", "($lon,$lat)"),
    ("size", "@size"),
    ("width","@width")
    ])

bound = 200 # meters

fig = figure(tools = [hover],x_range=(-bound, bound),
             y_range=(-bound, bound))

fig.add_tools(WheelZoomTool(),PanTool(),SaveTool(), ResetTool())
fig.toolbar.active_scroll = WheelZoomTool()
fig.axis.visible = True

fig.segment(x0='lon0', y0='lat0', x1='lon1',
          y1='lat1', color="#F4A582", line_width='width', source=source_lines)

fig.circle('lon','lat', fill_color='red', size = 'size', source=source_circles)

fig.axis.visible = True
fig.add_tile(CARTODBPOSITRON)
output_file("Rectangle around Bangladesh.html")
show(fig)

On Sunday, 12 March 2017 22:11:44 UTC+1, Bryan Van de ven wrote:
Hi,

The "out of frame" problem is due to some change on Google's end. However, this problem has recently been fixed in master and will be in the next release. It is also available in the latest dev builds.

The save button can only save what is on the HTML canvas currently which means it cannot work with GMaps, unfortunately (they render in a separate DOM element).

Regarding the other issue you mention, I think that was also recently fixed in master (there is a pile of GMap improvements and fixes going in the next release) but it's not possible to know for sure without code to run.

I think you will find GMap significantly improved when 0.12.5 is released. However, if "save" is a mandatory requirement for you, then I think for now your only option is the TileRenderer (e.g. Stamen) plots. If you have suggestions that would help with specifying coordinates, etc. please make feature requests on GitHub:

        https://github.com/bokeh/bokeh/issues

It's almost always better when feature development proceeds from concrete user use-cases so your input would be valuable.

Thanks,

Bryan

> On Mar 11, 2017, at 17:39, Tim <[email protected]> wrote:
>
> Hello everyone,
>
> I'm new to Bokeh and I'm having some problems using it. I will try to describe my problems and purpose as complete as possible, but feel free to skip irrelevant parts of my post.
>
> Purpose:
> Plot roads and bridges in Bangladesh on a map, to give insight in the vulnerability of these roads and bridges.
>
> How:
> Plot roads as lines in the map and use width and color as metrics to indicate certain vulnerability indicators
> Plot bridges as dots in the map and use size and color ~~
>
> Progress:
> At this point I'm exploring Bokeh's functionalities. I have made different maps with using GMapPlot and Stamen map.
> I found it difficult to work with coordinates in Stamen (I don't have much knowledge of JSTOR), so I decided to use GMapPlot, since it handles coordinates more easily.
>
> I started with plotting some random points in Bangladesh and that works
> I wanted to plot a square around bangladesh and this doesn't work.
> At this point I have no clue what the problem could be, because I don't get errors
>
>
> Problems at this point:
> • I want to plot 2 glyphs on the map (circles and lines), The points work, but the lines don't
> • If I add both lines and circles, the lines are not plotted
> • If I comment out the circles, the lines glyph appears and then disappears again.
> • The save button let's me download a file, but the picture shows nothing.
> • The map is plotted out of it's frame (both with using chrome and edge browsers
>
>
> Additional question:
> - Are there known disadvantages of using GMapPlot? Do you recommend me to use Stamen in combination with JSTOR?
>
> I'm looking forward to receiving some feedback.
>
> Regards,
> Tim
>
> Attachements:
> • Bokeh html file
> • Python code
> • Jupyter Notebook File
> • Below I also pasted the code I used
>
>
>
> Python code (Python 3 and working in Jupyter notebooks 4.3.1)
>
> from bokeh.io import output_file, show
> from bokeh.models import (
> GMapPlot, GMapOptions, ColumnDataSource, Circle, DataRange1d,
> PanTool, WheelZoomTool, BoxSelectTool, SaveTool, )
> from bokeh.models.glyphs import Segment
>
> map_options = GMapOptions(lat=24, lng=90, map_type="roadmap", zoom=7)
>
> plot = GMapPlot(
> x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options
> )
> plot.title.text = "Bangladesh"
>
>
> # https://developers.google.com/maps/documentation/javascript/get-api-key
> plot.api_key = "AIzaSyD27PG4tV85tftwwxSn-Rl2RVSoFqjxtVw"
>
>
> # Load in Bangladesh Data
> source_lines = ColumnDataSource(
> data = dict(
> lon0=[88,88,92,92], #x
> lon1=[88,92,92,88], #x
> lat0=[20,26,20,20], #y
> lat1=[26,26,26,20], #y
> width=[2,4,6,8]))
>
> source_points = ColumnDataSource(
> data=dict(
> lat = [20,26,20,26,23.81],
> lon = [88,88,92,92,90.4],
> size = [9,9,9,9,10],
> info = ["a","b","c","d","Dhaka"]
> )
> )
>
>
>
> # circle = Circle(x="lon", y="lat", size='size', fill_color="blue", fill_alpha=0.8, line_color=None)
> # plot.add_glyph(source_points, circle)
>
> lines = Segment(x0='lon0', y0='lat0', x1='lon1',
> y1='lat1', line_color="red", line_width=100)
> plot.add_glyph(source_lines, lines)
>
>
> plot.add_tools(PanTool(), WheelZoomTool(), SaveTool())
> output_file("gmap_plot.html")
> show(plot)
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/20416263-5221-4c3e-aab1-81e49681be3a%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.
> <gmap_plot.html><Test map-2-clean-v6.ipynb>

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1242741e-1237-4171-83ab-478b8467c78c%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks Bryan!

For anyone who has the same problem:

This is a solution to mapping geometry coordinates to the web mercator projection used by Cartodb.

import pyproj

coordinates Eiffel Tower

latitude, longitude = 48.858093, 2.294694

proj1 = pyproj.Proj(init=‘epsg:4283’)

proj2 = pyproj.Proj(init=‘epsg:3857’)

new_lon, new_lat = pyproj.transform(proj1, proj2, longitude, latitude)

``

···

On Monday, 13 March 2017 15:12:55 UTC+1, Bryan Van de ven wrote:

The coordinates used by the TileRenderer are web mercator coordinates. The most direct solution is probably simply to convert your lat/lon coordinates for the lines and circles, into web mercator, using any of the existing python libraries for computing map projections.

Alternatively, you could try adding an ‘extra range’ as decscribed here:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#twin-axes](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#twin-axes)

That example happens to also add a second axis for the extra range, but that’s purely optional You could add an extra range just to drive glyphs from. I would note, however, that I cannot be certain this approach would work well when zoomed out. Bokeh tries to maintain the relative relationship between ranges across any panning and zooming, which works great for cartesian coordinates. I am not sure that will work across all scales once map projections are involved.

Thanks,

Bryan

On Mar 13, 2017, at 05:46, Tim [email protected] wrote:

Hi Bryan,

Thank you for your reply. I decided to change my approach and I’m running into a new problem.

With this code, I’m able to plot an rectangle with 4 points and 4 lines.However, it doesn’t use Lat Lon inputs. How do I change my input coordinates to Lat Lon?

My code:

from bokeh.io import output_file, show

from bokeh.plotting import figure

from bokeh.tile_providers import STAMEN_TONER, STAMEN_TERRAIN, CARTODBPOSITRON

from bokeh.plotting import ColumnDataSource

from bokeh.models import HoverTool

from bokeh.models import WheelZoomTool, PanTool, SaveTool, ResetTool

source_lines = ColumnDataSource(

data = dict(
lon0=[88,88,92,92],  #x
lon1=[88,92,92,88],  #x
lat0=[20,26,20,20],  #y
lat1=[26,26,26,20],  #y
width=[2,4,6,8]))

source_circles = ColumnDataSource(

data = dict(
lat = [20,26,20,26],
lon = [88,88,92,92],
size = [5,2,3,7],
width = ["a","b","c","d"]
))

hover = HoverTool(

tooltips=[
("index","$index"),
("(x,y)", "($lon,$lat)"),
("size", "@size"),
("width","@width")
])

bound = 200 # meters

fig = figure(tools = [hover],x_range=(-bound, bound),

         y_range=(-bound, bound))

fig.add_tools(WheelZoomTool(),PanTool(),SaveTool(), ResetTool())

fig.toolbar.active_scroll = WheelZoomTool()

fig.axis.visible = True

fig.segment(x0=‘lon0’, y0=‘lat0’, x1=‘lon1’,

      y1='lat1', color="#F4A582", line_width='width', source=source_lines)

fig.circle(‘lon’,‘lat’, fill_color=‘red’, size = ‘size’, source=source_circles)

fig.axis.visible = True

fig.add_tile(CARTODBPOSITRON)

output_file(“Rectangle around Bangladesh.html”)

show(fig)

On Sunday, 12 March 2017 22:11:44 UTC+1, Bryan Van de ven wrote:

Hi,

The “out of frame” problem is due to some change on Google’s end. However, this problem has recently been fixed in master and will be in the next release. It is also available in the latest dev builds.

The save button can only save what is on the HTML canvas currently which means it cannot work with GMaps, unfortunately (they render in a separate DOM element).

Regarding the other issue you mention, I think that was also recently fixed in master (there is a pile of GMap improvements and fixes going in the next release) but it’s not possible to know for sure without code to run.

I think you will find GMap significantly improved when 0.12.5 is released. However, if “save” is a mandatory requirement for you, then I think for now your only option is the TileRenderer (e.g. Stamen) plots. If you have suggestions that would help with specifying coordinates, etc. please make feature requests on GitHub:

    [https://github.com/bokeh/bokeh/issues](https://github.com/bokeh/bokeh/issues)

It’s almost always better when feature development proceeds from concrete user use-cases so your input would be valuable.

Thanks,

Bryan

On Mar 11, 2017, at 17:39, Tim [email protected] wrote:

Hello everyone,

I’m new to Bokeh and I’m having some problems using it. I will try to describe my problems and purpose as complete as possible, but feel free to skip irrelevant parts of my post.

Purpose:
Plot roads and bridges in Bangladesh on a map, to give insight in the vulnerability of these roads and bridges.

How:
Plot roads as lines in the map and use width and color as metrics to indicate certain vulnerability indicators
Plot bridges as dots in the map and use size and color ~~

Progress:
At this point I’m exploring Bokeh’s functionalities. I have made different maps with using GMapPlot and Stamen map.
I found it difficult to work with coordinates in Stamen (I don’t have much knowledge of JSTOR), so I decided to use GMapPlot, since it handles coordinates more easily.

I started with plotting some random points in Bangladesh and that works
I wanted to plot a square around bangladesh and this doesn’t work.
At this point I have no clue what the problem could be, because I don’t get errors

Problems at this point:
• I want to plot 2 glyphs on the map (circles and lines), The points work, but the lines don’t
• If I add both lines and circles, the lines are not plotted
• If I comment out the circles, the lines glyph appears and then disappears again.
• The save button let’s me download a file, but the picture shows nothing.
• The map is plotted out of it’s frame (both with using chrome and edge browsers

Additional question:

  • Are there known disadvantages of using GMapPlot? Do you recommend me to use Stamen in combination with JSTOR?

I’m looking forward to receiving some feedback.

Regards,
Tim

Attachements:
• Bokeh html file
• Python code
• Jupyter Notebook File
• Below I also pasted the code I used

Python code (Python 3 and working in Jupyter notebooks 4.3.1)

from bokeh.io import output_file, show
from bokeh.models import (
GMapPlot, GMapOptions, ColumnDataSource, Circle, DataRange1d,
PanTool, WheelZoomTool, BoxSelectTool, SaveTool, )
from bokeh.models.glyphs import Segment

map_options = GMapOptions(lat=24, lng=90, map_type=“roadmap”, zoom=7)

plot = GMapPlot(
x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options
)
plot.title.text = “Bangladesh”

https://developers.google.com/maps/documentation/javascript/get-api-key

plot.api_key = “AIzaSyD27PG4tV85tftwwxSn-Rl2RVSoFqjxtVw”

Load in Bangladesh Data

source_lines = ColumnDataSource(
data = dict(
lon0=[88,88,92,92], #x
lon1=[88,92,92,88], #x
lat0=[20,26,20,20], #y
lat1=[26,26,26,20], #y
width=[2,4,6,8]))

source_points = ColumnDataSource(
data=dict(
lat = [20,26,20,26,23.81],
lon = [88,88,92,92,90.4],
size = [9,9,9,9,10],
info = [“a”,“b”,“c”,“d”,“Dhaka”]
)
)

circle = Circle(x=“lon”, y=“lat”, size=‘size’, fill_color=“blue”, fill_alpha=0.8, line_color=None)

plot.add_glyph(source_points, circle)

lines = Segment(x0=‘lon0’, y0=‘lat0’, x1=‘lon1’,
y1=‘lat1’, line_color=“red”, line_width=100)
plot.add_glyph(source_lines, lines)

plot.add_tools(PanTool(), WheelZoomTool(), SaveTool())
output_file(“gmap_plot.html”)
show(plot)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/20416263-5221-4c3e-aab1-81e49681be3a%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
<gmap_plot.html>


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1242741e-1237-4171-83ab-478b8467c78c%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.