Plot a world map

I would like to use bokeh to display the world map (as image, in fixed 2:1 ratio) and draw points on it.
Seems fairly simple objective, but I’ve no idea on how to start. I don’t think that “tiles” is what I am
looking for.

Any ideas?

Hi Artur

I was curious about this as well but have not had any success yet. I am trying with some geojson data from github but you may have better luck finding better map data.

I was seeing the warning in the browser console ‘could not set initial ranges’ so I set these manually (though I don’t think that is the right long term approach). I still see the console warning ‘Bokeh does not support Polygons with holes in, only exterior ring used.’ At this point, no shapes are being rendered to the figure. Similar code in the examples with Texas counties and US counties do work, so it’s probably something about the format of the data. Maybe others with mapping experience in Bokeh can weigh in.

Here’s the code I’m testing in the notebook with 0.11.1

from bokeh.io import output_notebook

output_notebook()

import bokeh

print(bokeh.version)

from bokeh.io import show

from bokeh.models import GeoJSONDataSource

from bokeh.plotting import figure

from bokeh.sampledata.sample_geojson import geojson

import geojson # used for getting a flat list of lat/long from the geojson data

import requests

url = ‘https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json

some other data sources I tried

#url = ‘https://raw.githubusercontent.com/intridea/world.geo.json/master/countries/AGO.json

#url = ‘https://raw.githubusercontent.com/intridea/world.geo.json/master/countries/VAT.json

#url = ‘https://raw.githubusercontent.com/intridea/world.geo.json/master/countries.topojson.json

r = requests.get(url)

json_string = r.content.decode(‘utf-8’)

geo_json_data = r.json()

country_xs, country_ys = zip(*geojson.utils.coords(geo_json_data[‘features’]))

p = figure(plot_width=600, plot_height=400, x_range=(-180,180), y_range=(-90,90))

p.patches(country_xs, country_ys, fill_color="#F1EEF6", fill_alpha=0.7)

show§

···

On Mon, Feb 29, 2016 at 4:25 PM Artur Scholz artur.scholz.79[email protected] wrote:

I would like to use bokeh to display the world map (as image, in fixed 2:1 ratio) and draw points on it.
Seems fairly simple objective, but I’ve no idea on how to start. I don’t think that “tiles” is what I am
looking for.

Any ideas?

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/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io.

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

Hi Dennis,

thanks for the hints. However, what I try to accomplish is something much simpler: to load an image (worldmap) with
fixed ratio, and draw upon it. I’ve done this with Qt, OpenGL, PyQt, etc. for the desktop
Now I want this for the web.

(The objective is to use that for plotting spacecraft ground tracks)

Seems to be a fairly easy challenge… ?

Artur

···

On Tuesday, March 1, 2016 at 10:22:20 AM UTC+1, Dennis O’Brien wrote:

Hi Artur

I was curious about this as well but have not had any success yet. I am trying with some geojson data from github but you may have better luck finding better map data.

I was seeing the warning in the browser console ‘could not set initial ranges’ so I set these manually (though I don’t think that is the right long term approach). I still see the console warning ‘Bokeh does not support Polygons with holes in, only exterior ring used.’ At this point, no shapes are being rendered to the figure. Similar code in the examples with Texas counties and US counties do work, so it’s probably something about the format of the data. Maybe others with mapping experience in Bokeh can weigh in.

Here’s the code I’m testing in the notebook with 0.11.1

from bokeh.io import output_notebook

output_notebook()

import bokeh

print(bokeh.version)

from bokeh.io import show

from bokeh.models import GeoJSONDataSource

from bokeh.plotting import figure

from bokeh.sampledata.sample_geojson import geojson

import geojson # used for getting a flat list of lat/long from the geojson data

import requests

url = ‘https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json

some other data sources I tried

#url = ‘https://raw.githubusercontent.com/intridea/world.geo.json/master/countries/AGO.json

#url = ‘https://raw.githubusercontent.com/intridea/world.geo.json/master/countries/VAT.json

#url = ‘https://raw.githubusercontent.com/intridea/world.geo.json/master/countries.topojson.json

r = requests.get(url)

json_string = r.content.decode(‘utf-8’)

geo_json_data = r.json()

country_xs, country_ys = zip(*geojson.utils.coords(geo_json_data[‘features’]))

p = figure(plot_width=600, plot_height=400, x_range=(-180,180), y_range=(-90,90))

p.patches(country_xs, country_ys, fill_color="#F1EEF6", fill_alpha=0.7)

show§

On Mon, Feb 29, 2016 at 4:25 PM Artur Scholz [email protected] wrote:

I would like to use bokeh to display the world map (as image, in fixed 2:1 ratio) and draw points on it.
Seems fairly simple objective, but I’ve no idea on how to start. I don’t think that “tiles” is what I am
looking for.

Any ideas?

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/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io.

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

Hi Dennis,

I took a quick look at your example.
I think, you need to check if a country has several borders
I do not know the geojson library, so I have written a get_coordinates function. It's ugly but it seems to work.
I used python2.7 and bokeh 0.12.0dev1-96-gcf82e80

from __future__ import print_function

import requests
import numpy as np

import bokeh
print(bokeh.__version__)

from bokeh.io import output_file, show
from bokeh.models import GeoJSONDataSource
from bokeh.plotting import figure

url = 'https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json'

r = requests.get(url)
geo_json_data = r.json()

def get_coordinates(features):
     depth = lambda L: isinstance(L, list) and max(map(depth, L))+1
     xs =
     ys =
     for feature in geo_json_data['features']:
         coords = feature['geometry']['coordinates']
         nbdims = depth(coords)
         # one border
         if nbdims == 3:
             pts = np.array(coords[0], 'f')
             xs.append(pts[:, 0])
             ys.append(pts[:, 1])
         # several borders
         else:
             for shape in coords:
                 pts = np.array(shape[0], 'f')
                 xs.append(pts[:, 0])
                 ys.append(pts[:, 1])
     return xs, ys

xs, ys = get_coordinates(geo_json_data['features'])
p = figure(plot_width=900, plot_height=600, x_range=(-180,180), y_range=(-90,90))
p.patches(xs, ys, fill_color="#F1EEF6", fill_alpha=0.7, line_width=2)

output_file("test.html")
show(p)

···

Le 01/03/2016 11:53, Artur Scholz a écrit :

Hi Dennis,

thanks for the hints. However, what I try to accomplish is something
much simpler: to load an image (worldmap) with
fixed ratio, and draw upon it. I've done this with Qt, OpenGL, PyQt,
etc. for the desktop
Now I want this for the web.

(The objective is to use that for plotting spacecraft ground tracks)

Seems to be a fairly easy challenge... ?

Artur

On Tuesday, March 1, 2016 at 10:22:20 AM UTC+1, Dennis O'Brien wrote:

    Hi Artur

    I was curious about this as well but have not had any success yet.
    I am trying with some geojson data from github but you may have
    better luck finding better map data.

    I was seeing the warning in the browser console 'could not set
    initial ranges' so I set these manually (though I don't think that
    is the right long term approach). I still see the console warning
    'Bokeh does not support Polygons with holes in, only exterior ring
    used.' At this point, no shapes are being rendered to the figure.
    Similar code in the examples with Texas counties and US counties do
    work, so it's probably something about the format of the data.
    Maybe others with mapping experience in Bokeh can weigh in.

    Here's the code I'm testing in the notebook with 0.11.1

    from bokeh.io <http://bokeh.io> import output_notebook
    output_notebook()
    import bokeh
    print(bokeh.__version__)
    from bokeh.io <http://bokeh.io> import show
    from bokeh.models import GeoJSONDataSource
    from bokeh.plotting import figure
    from bokeh.sampledata.sample_geojson import geojson
    import geojson # used for getting a flat list of lat/long from the
    geojson data
    import requests

    url =
    'https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json
    <https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json>'
    # some other data sources I tried
    #url =
    'https://raw.githubusercontent.com/intridea/world.geo.json/master/countries/AGO.json
    <https://raw.githubusercontent.com/intridea/world.geo.json/master/countries/AGO.json>'
    #url =
    'https://raw.githubusercontent.com/intridea/world.geo.json/master/countries/VAT.json
    <https://raw.githubusercontent.com/intridea/world.geo.json/master/countries/VAT.json>'
    #url =
    'https://raw.githubusercontent.com/intridea/world.geo.json/master/countries.topojson.json
    <https://raw.githubusercontent.com/intridea/world.geo.json/master/countries.topojson.json>'
    r = requests.get(url)
    # json_string = r.content.decode('utf-8')
    geo_json_data = r.json()

    country_xs, country_ys =
    zip(*geojson.utils.coords(geo_json_data['features']))
    p = figure(plot_width=600, plot_height=400, x_range=(-180,180),
    y_range=(-90,90))
    p.patches(country_xs, country_ys, fill_color="#F1EEF6", fill_alpha=0.7)

    show(p)

    On Mon, Feb 29, 2016 at 4:25 PM Artur Scholz <[email protected] > <javascript:>> wrote:

        I would like to use bokeh to display the world map (as image, in
        fixed 2:1 ratio) and draw points on it.
        Seems fairly simple objective, but I've no idea on how to start.
        I don't think that "tiles" is what I am
        looking for.

        Any ideas?

        --
        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] <javascript:>.
        To post to this group, send email to [email protected]
        <javascript:>.
        To view this discussion on the web visit
        https://groups.google.com/a/continuum.io/d/msgid/bokeh/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io
        <https://groups.google.com/a/continuum.io/d/msgid/bokeh/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io?utm_medium=email&utm_source=footer>.
        For more options, visit
        https://groups.google.com/a/continuum.io/d/optout
        <https://groups.google.com/a/continuum.io/d/optout>.

--
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]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/e717c75c-3a48-4c9e-9637-11c99beb9893%40continuum.io
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/e717c75c-3a48-4c9e-9637-11c99beb9893%40continuum.io?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Artur,

      It sounds to me like tiles *would* be the easiest way to                       get your world background

and then you can draw
points on it. Why do
you not want tiles?

                                                  Here's an example

using tiles.

                          Sincerely,

                            Sarah Bird
···

On 2/29/16 4:25 PM, Artur Scholz wrote:

    I would like to use bokeh to display the world map (as image, in

fixed 2:1 ratio) and draw points on it.

    Seems fairly simple objective, but I've no idea on how to start.

I don’t think that “tiles” is what I am

    looking for.



    Any ideas?

  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/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io?utm_medium=email&utm_source=footer)      .

For more options, visit .


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

https://groups.google.com/a/continuum.io/d/msgid/bokeh/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io
https://groups.google.com/a/continuum.io/d/optout

I just updated to show the 2:1 viewport:

···

http://nbviewer.jupyter.org/github/birdsarah/bokeh-miscellany/blob/master/World%20Map.ipynb?flush_cache=True

I ac tually
think you need to go further and set the ranges / bounds to be what you want them to be.

Having said that I played a round
with it a little and wasn’t very happy with the interaction. I don’t have much time to play with it now.

                        Do                                 let us know how

you get on.

                            Best,

                              Bird

  On 3/4/16 3:45 PM, Sarah Bird -

Continuum wrote:

Hi Artur,

        It sounds to me like tiles *would* be
                the easiest way to                         get your world background

and then you can
draw points on it. Why do you not want tiles?

                                                      Here's an

example using tiles.

                            Sincerely,



                              Sarah Bird


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

    On 2/29/16 4:25 PM, Artur Scholz

wrote:

      I would like to use bokeh to display the world map (as image,

in fixed 2:1 ratio) and draw points on it.

      Seems fairly simple objective, but I've no idea on how to

start. I don’t think that “tiles” is what I am

      looking for.



      Any ideas?

    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 .

For more options, visit .
https://groups.google.com/a/continuum.io/d/msgid/bokeh/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io
https://groups.google.com/a/continuum.io/d/optout


Sarah Bird
Developer, Bokeh

      [ ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png) ](http://continuum.io)

Dear Sarah,

thanks for the reply and sorry for my late response. Although your solutions kind of solves my problem, it is still

not what I want. In particular, I do not need a live map, and dont want to see the CC notice on the bottom.

So let’s make it even simpler: How to load an image (png, jpeg,…) and have it shown via bokeh, as the background
of the plot?

Thanks

Artur

···

On Sat, Mar 5, 2016 at 12:56 AM, Sarah Bird - Continuum [email protected] wrote:

I just updated to show the 2:1 viewport:

http://nbviewer.jupyter.org/github/birdsarah/bokeh-miscellany/blob/master/World%20Map.ipynb?flush_cache=True

        I ac                tually

think you need to go further and set the ranges / bounds to be what you want them to be.

        Having said that I played a                  round

with it a little and wasn’t very happy with the interaction. I don’t have much time to play with it now.

                        Do                                 let us know how

you get on.

                            Best,



                              Bird



  On 3/4/16 3:45 PM, Sarah Bird -

Continuum wrote:

Hi Artur,

        It sounds to me like tiles *would* be
                the easiest way to                         get your world background

and then you can
draw points on it. Why do you not want tiles?

                                                      Here's an

example using tiles.

                            Sincerely,



                              Sarah Bird






    On 2/29/16 4:25 PM, Artur Scholz

wrote:

      I would like to use bokeh to display the world map (as image,

in fixed 2:1 ratio) and draw points on it.

      Seems fairly simple objective, but I've no idea on how to

start. I don’t think that “tiles” is what I am

      looking for.



      Any ideas?

    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/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io).

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


Sarah Bird
Developer, Bokeh

      [ ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png) ](http://continuum.io)


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

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

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/cJ7tzsm1aLc/unsubscribe.

To unsubscribe from this group and all its topics, 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/56DA2097.2010602%40continuum.io.

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

Dear Sarah,

thanks for the reply and sorry for my late response. Although your solutions kind of solves my problem, it is still
not what I want. In particular, I do not need a live map, and dont want to see the CC notice on the bottom.

Displaying CC notice is part of the Terms of Use for pretty much all map service providers, so if that's a no-go for you then you are correct that maps/tiles are not what you want.

So let's make it even simpler: How to load an image (png, jpeg,...) and have it shown via bokeh, as the background
of the plot?

If the image is available via URL then you can use `image_url`

  p = figure()
  p.image_url(...)

Otherwise, you would have to convert the image to a 2D array of RGBA data and use `image`

  http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#images

If you have the ability to contribute, adding support for accepting common image types to p.image(...), or even just some conversion functions that people could easily use to get the required RGBA arrays more easily, would be a welcome addition.

Thanks,

Bryan

···

On Mar 17, 2016, at 8:09 AM, Artur Scholz <[email protected]> wrote:

Thanks
Artur

On Sat, Mar 5, 2016 at 12:56 AM, Sarah Bird - Continuum <[email protected]> wrote:
I just updated to show the 2:1 viewport:

http://nbviewer.jupyter.org/github/birdsarah/bokeh-miscellany/blob/master/World%20Map.ipynb?flush_cache=True

I actually think you need to go further and set the ranges / bounds to be what you want them to be.

Having said that I played around with it a little and wasn't very happy with the interaction. I don't have much time to play with it now.

Do let us know how you get on.

Best,

Bird

On 3/4/16 3:45 PM, Sarah Bird - Continuum wrote:

Hi Artur,

It sounds to me like tiles *would* be the easiest way to get your world background and then you can draw points on it. Why do you not want tiles?

Here's an example using tiles.

Sincerely,

Sarah Bird

On 2/29/16 4:25 PM, Artur Scholz wrote:

I would like to use bokeh to display the world map (as image, in fixed 2:1 ratio) and draw points on it.
Seems fairly simple objective, but I've no idea on how to start. I don't think that "tiles" is what I am
looking for.

Any ideas?
--
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/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
Sarah Bird
Developer, Bokeh

--
Sarah Bird
Developer, Bokeh

--
You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/cJ7tzsm1aLc/unsubscribe.
To unsubscribe from this group and all its topics, 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/56DA2097.2010602%40continuum.io.

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

--
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/CALqfExZyqgM6wN9fQow%2B3%3DgB%3DjPeF9WWJwv_YWEzqkShBxEuWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Dear all,

the following python code works to display a 2d world map (or any image) using bokeh, and to draw glyph onto it.

My ultimate goal is then to draw and update glyphs (circle, lines, text) on the client browser, once every second.

The callback function I use in the code is however dead slow. For example, when going to full screen, the

display gets not updated and browser window starts to hang.

Is it really that the image glyph slows it down so much? Do I better look into using WebGl (e.g. Three.js)

for doing such stuff?

Cheers

Artur


<details class='elided'>
<summary title='Show trimmed content'>&#183;&#183;&#183;</summary>

On Thu, Mar 17, 2016 at 2:27 PM, Bryan Van de Ven <[email protected]> wrote:
> 
> 
> > On Mar 17, 2016, at 8:09 AM, Artur Scholz <[email protected]> wrote:
> 
> >
> 
> > Dear Sarah,
> 
> >
> 
> > thanks for the reply and sorry for my late response. Although your solutions kind of solves my problem, it is still
> 
> > not what I want. In particular, I do not need a live map, and dont want to see the CC notice on the bottom.
> 
> 
> 
> Displaying CC notice is part of the Terms of Use for pretty much all map service providers, so if that's a no-go for you then you are correct that maps/tiles are not what you want.
> 
> 
> 
> > So let's make it even simpler: How to load an image (png, jpeg,...) and have it shown via bokeh, as the background
> 
> > of the plot?
> 
> 
> 
> If the image is available via URL then you can use `image_url`
> 
> 
> 
>         p = figure()
> 
>         p.image_url(...)
> 
> 
> 
> Otherwise, you would have to convert the image to a 2D array of RGBA data and use `image`
> 
> 
> 
>         [http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#images](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#images)
> 
> 
> 
> If you have the ability to contribute, adding support for accepting common image types to p.image(...), or even just some conversion functions that people could easily use to get the required RGBA arrays more easily, would be a welcome addition.
> 
> 
> 
> Thanks,
> 
> 
> 
> Bryan
> 
> 
> >
> 
> > Thanks
> 
> > Artur
> 
> >
> 
> > On Sat, Mar 5, 2016 at 12:56 AM, Sarah Bird - Continuum <[email protected]> wrote:
> 
> > I just updated to show the 2:1 viewport:
> 
> >
> 
> > [http://nbviewer.jupyter.org/github/birdsarah/bokeh-miscellany/blob/master/World%20Map.ipynb?flush_cache=True](http://nbviewer.jupyter.org/github/birdsarah/bokeh-miscellany/blob/master/World%20Map.ipynb?flush_cache=True)
> 
> >
> 
> > I actually think you need to go further and set the ranges / bounds to be what you want them to be.
> 
> >
> 
> > Having said that I played around with it a little and wasn't very happy with the interaction. I don't have much time to play with it now.
> 
> >
> 
> > Do let us know how you get on.
> 
> >
> 
> > Best,
> 
> >
> 
> > Bird
> 
> >
> 
> > On 3/4/16 3:45 PM, Sarah Bird - Continuum wrote:
> 
> >> Hi Artur,
> 
> >>
> 
> >> It sounds to me like tiles *would* be the easiest way to get your world background and then you can draw points on it. Why do you not want tiles?
> 
> >>
> 
> >> Here's an example using tiles.
> 
> >>
> 
> >> Sincerely,
> 
> >>
> 
> >> Sarah Bird
> 
> >>
> 
> >>
> 
> >>
> 
> >> On 2/29/16 4:25 PM, Artur Scholz wrote:
> 
> >>>
> 
> >>> I would like to use bokeh to display the world map (as image, in fixed 2:1 ratio) and draw points on it.
> 
> >>> Seems fairly simple objective, but I've no idea on how to start. I don't think that "tiles" is what I am
> 
> >>> looking for.
> 
> >>>
> 
> >>> Any ideas?
> 
> >>> --
> 
> >>> 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/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io).
> 
> >>> For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).
> 
> >>
> 
> >> --
> 
> >> Sarah Bird
> 
> >> Developer, Bokeh
> 
> >>
> 
> >>
> 
> >>
> 
> >
> 
> > --
> 
> > Sarah Bird
> 
> > Developer, Bokeh
> 
> >
> 
> >
> 
> >
> 
> >

> > --
> 
> > You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
> 
> > To unsubscribe from this topic, visit [https://groups.google.com/a/continuum.io/d/topic/bokeh/cJ7tzsm1aLc/unsubscribe](https://groups.google.com/a/continuum.io/d/topic/bokeh/cJ7tzsm1aLc/unsubscribe).
> 
> > To unsubscribe from this group and all its topics, 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/56DA2097.2010602%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/56DA2097.2010602%40continuum.io).
> 
> >
> 
> > For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).
> 
> >
> 
> >
> 
> > --
> 
> > 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/CALqfExZyqgM6wN9fQow%2B3%3DgB%3DjPeF9WWJwv_YWEzqkShBxEuWQ%40mail.gmail.com](https://groups.google.com/a/continuum.io/d/msgid/bokeh/CALqfExZyqgM6wN9fQow%2B3%3DgB%3DjPeF9WWJwv_YWEzqkShBxEuWQ%40mail.gmail.com).
> 
> > For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).
> 
> 
> 
> --
> 
> You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
> 
> To unsubscribe from this topic, visit [https://groups.google.com/a/continuum.io/d/topic/bokeh/cJ7tzsm1aLc/unsubscribe](https://groups.google.com/a/continuum.io/d/topic/bokeh/cJ7tzsm1aLc/unsubscribe).
> 
> To unsubscribe from this group and all its topics, 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/D5D03EF8-D575-4BD9-9DEB-4DE4CE184444%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/D5D03EF8-D575-4BD9-9DEB-4DE4CE184444%40continuum.io).
> For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).

</details>

Artur,

Have you tried using any of the tiled data source capability? That's going to be much more performant for displaying tiled map data, as well as work better across different zoom levels.

Thanks,

Bryan

···

On Apr 28, 2016, at 4:51 AM, Artur Scholz <[email protected]> wrote:

Dear all,

the following python code works to display a 2d world map (or any image) using bokeh, and to draw glyph onto it.
My ultimate goal is then to draw and update glyphs (circle, lines, text) on the client browser, once every second.

The callback function I use in the code is however dead slow. For example, when going to full screen, the
display gets not updated and browser window starts to hang.

Is it really that the image glyph slows it down so much? Do I better look into using WebGl (e.g. Three.js)
for doing such stuff?

Cheers
Artur

-------------------------------------------------------------------------------
#!/usr/bin/env python3
"""Display 2d World Map"""

import numpy as
np

from PIL import
Image

from bokeh.plotting import figure, curdoc

p
= figure(webgl=True, responsive=True, plot_width=200, plot_height=100,

           x_range
=(-180, 180), y_range=(-90, 90),

           toolbar_location
=None, tools="")

img_file
= Image.open("data/earth.png")

img_width
= img_file.
width
img_height
= img_file.
height
img_data
= list(img_file.getdata())

# convert PNG image to RGBA array for bokeh

img
= np.empty((img_height, img_width), dtype=np.uint32)

view
= img.view(dtype=np.uint8).reshape((img_height, img_width, 4))
for h in range(img_height):

for w in range(img_width):

        H
= img_height-h-1

        view
[H, w, 0] = img_data[(h * img_width) + w][0]

        view
[H, w, 1] = img_data[(h * img_width) + w][1]

        view
[H, w, 2] = img_data[(h * img_width) + w][2]

        view
[H, w, 3] = 255

# add image to plot

p
.image_rgba(image=[img], x=[-180], y=[-90], dw=[360], dh=[180])

i
= 0
def callback():

global i

    p
.circle(i, 0, 10, color="blue") # add new circle to plot

    i
= i + 1

# generate output

curdoc
().add_root(p)

curdoc
().add_periodic_callback(callback, 1000)

-------------------------------------------------------------------------------

On Thu, Mar 17, 2016 at 2:27 PM, Bryan Van de Ven <[email protected]> wrote:

> On Mar 17, 2016, at 8:09 AM, Artur Scholz <[email protected]> wrote:
>
> Dear Sarah,
>
> thanks for the reply and sorry for my late response. Although your solutions kind of solves my problem, it is still
> not what I want. In particular, I do not need a live map, and dont want to see the CC notice on the bottom.

Displaying CC notice is part of the Terms of Use for pretty much all map service providers, so if that's a no-go for you then you are correct that maps/tiles are not what you want.

> So let's make it even simpler: How to load an image (png, jpeg,...) and have it shown via bokeh, as the background
> of the plot?

If the image is available via URL then you can use `image_url`

        p = figure()
        p.image_url(...)

Otherwise, you would have to convert the image to a 2D array of RGBA data and use `image`

        http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#images

If you have the ability to contribute, adding support for accepting common image types to p.image(...), or even just some conversion functions that people could easily use to get the required RGBA arrays more easily, would be a welcome addition.

Thanks,

Bryan

>
> Thanks
> Artur
>
> On Sat, Mar 5, 2016 at 12:56 AM, Sarah Bird - Continuum <[email protected]> wrote:
> I just updated to show the 2:1 viewport:
>
> http://nbviewer.jupyter.org/github/birdsarah/bokeh-miscellany/blob/master/World%20Map.ipynb?flush_cache=True
>
> I actually think you need to go further and set the ranges / bounds to be what you want them to be.
>
> Having said that I played around with it a little and wasn't very happy with the interaction. I don't have much time to play with it now.
>
> Do let us know how you get on.
>
> Best,
>
> Bird
>
> On 3/4/16 3:45 PM, Sarah Bird - Continuum wrote:
>> Hi Artur,
>>
>> It sounds to me like tiles *would* be the easiest way to get your world background and then you can draw points on it. Why do you not want tiles?
>>
>> Here's an example using tiles.
>>
>> Sincerely,
>>
>> Sarah Bird
>>
>>
>>
>> On 2/29/16 4:25 PM, Artur Scholz wrote:
>>>
>>> I would like to use bokeh to display the world map (as image, in fixed 2:1 ratio) and draw points on it.
>>> Seems fairly simple objective, but I've no idea on how to start. I don't think that "tiles" is what I am
>>> looking for.
>>>
>>> Any ideas?
>>> --
>>> 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/30ec4a0a-e8da-4075-a9fb-a8212c48a786%40continuum.io.
>>> For more options, visit https://groups.google.com/a/continuum.io/d/optout.
>>
>> --
>> Sarah Bird
>> Developer, Bokeh
>>
>>
>>
>
> --
> Sarah Bird
> Developer, Bokeh
>
>
>
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/cJ7tzsm1aLc/unsubscribe.
> To unsubscribe from this group and all its topics, 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/56DA2097.2010602%40continuum.io.
>
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.
>
>
> --
> 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/CALqfExZyqgM6wN9fQow%2B3%3DgB%3DjPeF9WWJwv_YWEzqkShBxEuWQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/cJ7tzsm1aLc/unsubscribe.
To unsubscribe from this group and all its topics, 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/D5D03EF8-D575-4BD9-9DEB-4DE4CE184444%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/CALqfExZs%3D1iJwoFmQ9SZWPEiTkvrMqKhnVPdSxhOrvf-4_SsFw%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.