How to create custom country maps?

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

···

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%40continuum.io.

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

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

···

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

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/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%40continuum.io.

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

Hi Martin,

I’m sorry I don’t have time to give you a more detailed answer. In my case I very crudely pulled the coordinates out of geojson Polygons (http://geojson.org/geojson-spec.html#id4) & Multipolygons (http://geojson.org/geojson-spec.html#id7). You can see the code here: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/main/utils.py#L43

The core bokeh examples (http://bokeh.pydata.org/en/latest/docs/gallery/choropleth.html & http://bokeh.pydata.org/en/latest/docs/gallery/texas.html) have data from a different source where it was slightly easier to pull it out.

I know that having better mapping support is something people want, but it’s not super easy just yet.

Best,

Bird

···

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%40mail.gmail.com.

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

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

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/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%40continuum.io.

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

Hey,

After seeing Sarah’s talk, i had a go at it myself, just trying to replicate the result with a different data source. I made a Python function (getAttributes) which converts an OGR (GDAL) vector data source to a Pandas DataFrame, which can then be readily used with Bokeh. A notebook showing it off can be found at:

Most code comes from Sarah’s example. Its using Dutch census data, but it should work with any other datasets as well, like Natural Earth for example (http://www.naturalearthdata.com/).

@Sarah, does your code work well for MultiPolygons? I dont see you inserting a ‘NaN’ between the separate parts in utils.py, wouldn’t that mean that the end of a part gets connected with a line to the start of another?

For some people GeoPandas might be an interesting module to combine with Bokeh, but on Windows its a pain to compile the dependencies, and there’s no Conda package.

Regards,
Rutger

···

On Tuesday, May 19, 2015 at 6:55:04 AM UTC+2, Sarah Bird wrote:

Hi Martin,

I’m sorry I don’t have time to give you a more detailed answer. In my case I very crudely pulled the coordinates out of geojson Polygons (http://geojson.org/geojson-spec.html#id4) & Multipolygons (http://geojson.org/geojson-spec.html#id7). You can see the code here: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/main/utils.py#L43

The core bokeh examples (http://bokeh.pydata.org/en/latest/docs/gallery/choropleth.html & http://bokeh.pydata.org/en/latest/docs/gallery/texas.html) have data from a different source where it was slightly easier to pull it out.

I know that having better mapping support is something people want, but it’s not super easy just yet.

Best,

Bird

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%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/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%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 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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%40mail.gmail.com.

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

Hi Martin, I did something similar a while ago, so I wrote up my solution and pushed it to github for you.

It includes a few lines to automatically download the required shape file data to whatever (local) folder you run the script from.

I requires you to have a few packages like osgeo, but it should work as is, all you would need to do is use the name of your country in the highlighted line and it will show you how to pull out the shape from the shapeless and plot it for you. I didn’t retroject or anything like that, so if you want it in a different co-ordinate system (which is very doable with PROJ4 and Pyproj) you will need to add a bit more work.

Also, there are a few bugs in some countries, as I did a bit of a hack job, just pulling out polygons from the shape files (which is why some of the countries are missing over Africa). I didn’t solve this before as I was focused on Scandinavia.

Anyway, the code is at: https://github.com/benlaken/Nbks (Bokeh_CountryMaps.ipynb)

Best,

—Benjamin

………………………………………………………………………………

Dr. Benjamin A. Laken FRMetS

www.benlaken.com Skype ben.laken

Postboks 1047 Blindern,   Tel.+47-2855827

0316, Oslo, Norway   Twitter  [benlaken](https://twitter.com/benlaken)
···

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%40mail.gmail.com.

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

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

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/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%40continuum.io.

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

Thanks both of you for help! I think I have enough to figure it out.

···

2015-05-19 10:46 GMT+02:00 Ben Laken [email protected]:

Hi Martin, I did something similar a while ago, so I wrote up my solution and pushed it to github for you.

It includes a few lines to automatically download the required shape file data to whatever (local) folder you run the script from.

I requires you to have a few packages like osgeo, but it should work as is, all you would need to do is use the name of your country in the highlighted line and it will show you how to pull out the shape from the shapeless and plot it for you. I didn’t retroject or anything like that, so if you want it in a different co-ordinate system (which is very doable with PROJ4 and Pyproj) you will need to add a bit more work.

Also, there are a few bugs in some countries, as I did a bit of a hack job, just pulling out polygons from the shape files (which is why some of the countries are missing over Africa). I didn’t solve this before as I was focused on Scandinavia.

Anyway, the code is at: https://github.com/benlaken/Nbks (Bokeh_CountryMaps.ipynb)

Best,

—Benjamin

………………………………………………………………………………

Dr. Benjamin A. Laken FRMetS

www.benlaken.com Skype ben.laken

Postboks 1047 Blindern, Tel.+47-2855827

0316, Oslo, Norway Twitter benlaken

On 19 May 2015, at 06:54, Sarah Bird [email protected] wrote:

Hi Martin,

I’m sorry I don’t have time to give you a more detailed answer. In my case I very crudely pulled the coordinates out of geojson Polygons (http://geojson.org/geojson-spec.html#id4) & Multipolygons (http://geojson.org/geojson-spec.html#id7). You can see the code here: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/main/utils.py#L43

The core bokeh examples (http://bokeh.pydata.org/en/latest/docs/gallery/choropleth.html & http://bokeh.pydata.org/en/latest/docs/gallery/texas.html) have data from a different source where it was slightly easier to pull it out.

I know that having better mapping support is something people want, but it’s not super easy just yet.

Best,

Bird

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/CA%2BEr%2BdRUS_hzw0VSZMFSPyHHje2ZRe%3DhwoE4TJO-cU6Dir1Uow%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 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/391510A0-63AF-4995-8FCA-74112DC12091%40gmail.com.

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

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%40mail.gmail.com.

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

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

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/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%40continuum.io.

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

Hi Rutger,

Thanks for posting this, that’s great. I did a hack job on multipolygons and didn’t put in a NaN in the final version (I think it was something wierd around hover on Patches not working so I didn’t want to do them for now). Luckily for me this hack is ok for Africa. You can’t see it clearly on the notebooks (http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb) but Angola is a multipolygon which I’ve joined like this and it does put a random line in, it’s just not v. noticeable.

There definitely was one in there at some point and I’ve forgotten why I took it out. I’m working on turning this demo into an example that’ll live in bokeh’s examples, so I will definitely make sure I do that properly then.

Thanks again for posting your code. v. helpful.

Bird

···

On Tue, May 19, 2015 at 12:58 AM, [email protected] wrote:

Hey,

After seeing Sarah’s talk, i had a go at it myself, just trying to replicate the result with a different data source. I made a Python function (getAttributes) which converts an OGR (GDAL) vector data source to a Pandas DataFrame, which can then be readily used with Bokeh. A notebook showing it off can be found at:
http://nbviewer.ipython.org/urls/gist.githubusercontent.com/RutgerK/e707239e1f82b3287a5d/raw/Bokeh_test

Most code comes from Sarah’s example. Its using Dutch census data, but it should work with any other datasets as well, like Natural Earth for example (http://www.naturalearthdata.com/).

@Sarah, does your code work well for MultiPolygons? I dont see you inserting a ‘NaN’ between the separate parts in utils.py, wouldn’t that mean that the end of a part gets connected with a line to the start of another?

For some people GeoPandas might be an interesting module to combine with Bokeh, but on Windows its a pain to compile the dependencies, and there’s no Conda package.

Regards,
Rutger

On Tuesday, May 19, 2015 at 6:55:04 AM UTC+2, Sarah Bird wrote:

Hi Martin,

I’m sorry I don’t have time to give you a more detailed answer. In my case I very crudely pulled the coordinates out of geojson Polygons (http://geojson.org/geojson-spec.html#id4) & Multipolygons (http://geojson.org/geojson-spec.html#id7). You can see the code here: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/main/utils.py#L43

The core bokeh examples (http://bokeh.pydata.org/en/latest/docs/gallery/choropleth.html & http://bokeh.pydata.org/en/latest/docs/gallery/texas.html) have data from a different source where it was slightly easier to pull it out.

I know that having better mapping support is something people want, but it’s not super easy just yet.

Best,

Bird

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%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]ntinuum.io.

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%40mail.gmail.com.

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

Rutger is it possible to share that shape file. I’d love to play with your code in more detail.

···

On Tue, May 19, 2015 at 10:57 AM, Sarah Bird [email protected] wrote:

Hi Rutger,

Thanks for posting this, that’s great. I did a hack job on multipolygons and didn’t put in a NaN in the final version (I think it was something wierd around hover on Patches not working so I didn’t want to do them for now). Luckily for me this hack is ok for Africa. You can’t see it clearly on the notebooks (http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb) but Angola is a multipolygon which I’ve joined like this and it does put a random line in, it’s just not v. noticeable.

There definitely was one in there at some point and I’ve forgotten why I took it out. I’m working on turning this demo into an example that’ll live in bokeh’s examples, so I will definitely make sure I do that properly then.

Thanks again for posting your code. v. helpful.

Bird

On Tue, May 19, 2015 at 12:58 AM, [email protected] wrote:

Hey,

After seeing Sarah’s talk, i had a go at it myself, just trying to replicate the result with a different data source. I made a Python function (getAttributes) which converts an OGR (GDAL) vector data source to a Pandas DataFrame, which can then be readily used with Bokeh. A notebook showing it off can be found at:
http://nbviewer.ipython.org/urls/gist.githubusercontent.com/RutgerK/e707239e1f82b3287a5d/raw/Bokeh_test

Most code comes from Sarah’s example. Its using Dutch census data, but it should work with any other datasets as well, like Natural Earth for example (http://www.naturalearthdata.com/).

@Sarah, does your code work well for MultiPolygons? I dont see you inserting a ‘NaN’ between the separate parts in utils.py, wouldn’t that mean that the end of a part gets connected with a line to the start of another?

For some people GeoPandas might be an interesting module to combine with Bokeh, but on Windows its a pain to compile the dependencies, and there’s no Conda package.

Regards,
Rutger

On Tuesday, May 19, 2015 at 6:55:04 AM UTC+2, Sarah Bird wrote:

Hi Martin,

I’m sorry I don’t have time to give you a more detailed answer. In my case I very crudely pulled the coordinates out of geojson Polygons (http://geojson.org/geojson-spec.html#id4) & Multipolygons (http://geojson.org/geojson-spec.html#id7). You can see the code here: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/main/utils.py#L43

The core bokeh examples (http://bokeh.pydata.org/en/latest/docs/gallery/choropleth.html & http://bokeh.pydata.org/en/latest/docs/gallery/texas.html) have data from a different source where it was slightly easier to pull it out.

I know that having better mapping support is something people want, but it’s not super easy just yet.

Best,

Bird

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%40mail.gmail.com.

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

I second that request - also if you have any more examples I would love to see them too - this is really great stuff!

···

On Tue, May 19, 2015 at 10:57 AM, Sarah Bird [email protected] wrote:

Hi Rutger,

Thanks for posting this, that’s great. I did a hack job on multipolygons and didn’t put in a NaN in the final version (I think it was something wierd around hover on Patches not working so I didn’t want to do them for now). Luckily for me this hack is ok for Africa. You can’t see it clearly on the notebooks (http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb) but Angola is a multipolygon which I’ve joined like this and it does put a random line in, it’s just not v. noticeable.

There definitely was one in there at some point and I’ve forgotten why I took it out. I’m working on turning this demo into an example that’ll live in bokeh’s examples, so I will definitely make sure I do that properly then.

Thanks again for posting your code. v. helpful.

Bird

On Tue, May 19, 2015 at 12:58 AM, [email protected] wrote:

Hey,

After seeing Sarah’s talk, i had a go at it myself, just trying to replicate the result with a different data source. I made a Python function (getAttributes) which converts an OGR (GDAL) vector data source to a Pandas DataFrame, which can then be readily used with Bokeh. A notebook showing it off can be found at:
http://nbviewer.ipython.org/urls/gist.githubusercontent.com/RutgerK/e707239e1f82b3287a5d/raw/Bokeh_test

Most code comes from Sarah’s example. Its using Dutch census data, but it should work with any other datasets as well, like Natural Earth for example (http://www.naturalearthdata.com/).

@Sarah, does your code work well for MultiPolygons? I dont see you inserting a ‘NaN’ between the separate parts in utils.py, wouldn’t that mean that the end of a part gets connected with a line to the start of another?

For some people GeoPandas might be an interesting module to combine with Bokeh, but on Windows its a pain to compile the dependencies, and there’s no Conda package.

Regards,
Rutger

On Tuesday, May 19, 2015 at 6:55:04 AM UTC+2, Sarah Bird wrote:

Hi Martin,

I’m sorry I don’t have time to give you a more detailed answer. In my case I very crudely pulled the coordinates out of geojson Polygons (http://geojson.org/geojson-spec.html#id4) & Multipolygons (http://geojson.org/geojson-spec.html#id7). You can see the code here: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/main/utils.py#L43

The core bokeh examples (http://bokeh.pydata.org/en/latest/docs/gallery/choropleth.html & http://bokeh.pydata.org/en/latest/docs/gallery/texas.html) have data from a different source where it was slightly easier to pull it out.

I know that having better mapping support is something people want, but it’s not super easy just yet.

Best,

Bird

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%40mail.gmail.com.

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

Off course, but i noticed they changed the format of the data a little, but here is an older version which still works:
http://www.cbs.nl/nl-NL/menu/themas/dossiers/nederland-regionaal/links/2012-wijk-en-buurtkaart-2009-3-el.htm

I used census data of 2011 which i had downloaded years ago, the link above contains data for 2009. The archive which you download contains three Shapefiles of different administrative levels. I used the highest one ‘gem_2009_gn3.shp’, which is at municipality level (gemeente). The three attributes i used are the total number of inhabitants, and broken down to male/female. The coordinate system of the Shapefile is Rijksdriehoek (RD new): http://spatialreference.org/ref/epsg/amersfoort-rd-new/

It might be necessary to convert the attributes of the Shapefile to UTF-8, i had to in Python 3. I did this by opening the Shapefile in QGIS, and choosing ‘save as’, and then select ‘utf-8’ as the ‘system’ in the save-dialog.

I also stumbled on a bug, my code plots the parts of multipolygons correctly (for as far as i can tell), but it does not plot inner rings (holes) correctly. It draws a line from the outer to the inner ring. I did a test where i also separate the inner ring with a ‘NaN’, but then it plots as a normal polygon, instead of a hole. I will try to come up with a solution, but the format of Bokeh’s Patches is not entirely clear to me. I would be interested in an example of Bokeh plotting Multipolygons with holes.

Regards,
Rutger

···

On Tuesday, May 19, 2015 at 8:02:47 PM UTC+2, Sarah Bird wrote:

Rutger is it possible to share that shape file. I’d love to play with your code in more detail.

On Tue, May 19, 2015 at 10:57 AM, Sarah Bird [email protected] wrote:

Hi Rutger,

Thanks for posting this, that’s great. I did a hack job on multipolygons and didn’t put in a NaN in the final version (I think it was something wierd around hover on Patches not working so I didn’t want to do them for now). Luckily for me this hack is ok for Africa. You can’t see it clearly on the notebooks (http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb) but Angola is a multipolygon which I’ve joined like this and it does put a random line in, it’s just not v. noticeable.

There definitely was one in there at some point and I’ve forgotten why I took it out. I’m working on turning this demo into an example that’ll live in bokeh’s examples, so I will definitely make sure I do that properly then.

Thanks again for posting your code. v. helpful.

Bird

On Tue, May 19, 2015 at 12:58 AM, [email protected] wrote:

Hey,

After seeing Sarah’s talk, i had a go at it myself, just trying to replicate the result with a different data source. I made a Python function (getAttributes) which converts an OGR (GDAL) vector data source to a Pandas DataFrame, which can then be readily used with Bokeh. A notebook showing it off can be found at:
http://nbviewer.ipython.org/urls/gist.githubusercontent.com/RutgerK/e707239e1f82b3287a5d/raw/Bokeh_test

Most code comes from Sarah’s example. Its using Dutch census data, but it should work with any other datasets as well, like Natural Earth for example (http://www.naturalearthdata.com/).

@Sarah, does your code work well for MultiPolygons? I dont see you inserting a ‘NaN’ between the separate parts in utils.py, wouldn’t that mean that the end of a part gets connected with a line to the start of another?

For some people GeoPandas might be an interesting module to combine with Bokeh, but on Windows its a pain to compile the dependencies, and there’s no Conda package.

Regards,
Rutger

On Tuesday, May 19, 2015 at 6:55:04 AM UTC+2, Sarah Bird wrote:

Hi Martin,

I’m sorry I don’t have time to give you a more detailed answer. In my case I very crudely pulled the coordinates out of geojson Polygons (http://geojson.org/geojson-spec.html#id4) & Multipolygons (http://geojson.org/geojson-spec.html#id7). You can see the code here: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/main/utils.py#L43

The core bokeh examples (http://bokeh.pydata.org/en/latest/docs/gallery/choropleth.html & http://bokeh.pydata.org/en/latest/docs/gallery/texas.html) have data from a different source where it was slightly easier to pull it out.

I know that having better mapping support is something people want, but it’s not super easy just yet.

Best,

Bird

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%40mail.gmail.com.

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

Hi Rutger,

Thanks for this.

“I also stumbled on a bug, my code plots the parts of multipolygons correctly (for as far as i can tell), but it does not plot inner rings (holes) correctly.”

There is currently no support for this in Bokeh. I have mentioned it to the core team and they’re keen to see that feature be implemented. I’m hoping to work on it over the coming month or so.

Best,

Bird

···

On Wed, May 20, 2015 at 3:04 AM, Rutger Kassies [email protected] wrote:

Off course, but i noticed they changed the format of the data a little, but here is an older version which still works:
http://www.cbs.nl/nl-NL/menu/themas/dossiers/nederland-regionaal/links/2012-wijk-en-buurtkaart-2009-3-el.htm

I used census data of 2011 which i had downloaded years ago, the link above contains data for 2009. The archive which you download contains three Shapefiles of different administrative levels. I used the highest one ‘gem_2009_gn3.shp’, which is at municipality level (gemeente). The three attributes i used are the total number of inhabitants, and broken down to male/female. The coordinate system of the Shapefile is Rijksdriehoek (RD new): http://spatialreference.org/ref/epsg/amersfoort-rd-new/

It might be necessary to convert the attributes of the Shapefile to UTF-8, i had to in Python 3. I did this by opening the Shapefile in QGIS, and choosing ‘save as’, and then select ‘utf-8’ as the ‘system’ in the save-dialog.

I also stumbled on a bug, my code plots the parts of multipolygons correctly (for as far as i can tell), but it does not plot inner rings (holes) correctly. It draws a line from the outer to the inner ring. I did a test where i also separate the inner ring with a ‘NaN’, but then it plots as a normal polygon, instead of a hole. I will try to come up with a solution, but the format of Bokeh’s Patches is not entirely clear to me. I would be interested in an example of Bokeh plotting Multipolygons with holes.

Regards,
Rutger

On Tuesday, May 19, 2015 at 8:02:47 PM UTC+2, Sarah Bird wrote:

Rutger is it possible to share that shape file. I’d love to play with your code in more detail.

On Tue, May 19, 2015 at 10:57 AM, Sarah Bird [email protected] wrote:

Hi Rutger,

Thanks for posting this, that’s great. I did a hack job on multipolygons and didn’t put in a NaN in the final version (I think it was something wierd around hover on Patches not working so I didn’t want to do them for now). Luckily for me this hack is ok for Africa. You can’t see it clearly on the notebooks (http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb) but Angola is a multipolygon which I’ve joined like this and it does put a random line in, it’s just not v. noticeable.

There definitely was one in there at some point and I’ve forgotten why I took it out. I’m working on turning this demo into an example that’ll live in bokeh’s examples, so I will definitely make sure I do that properly then.

Thanks again for posting your code. v. helpful.

Bird

On Tue, May 19, 2015 at 12:58 AM, [email protected] wrote:

Hey,

After seeing Sarah’s talk, i had a go at it myself, just trying to replicate the result with a different data source. I made a Python function (getAttributes) which converts an OGR (GDAL) vector data source to a Pandas DataFrame, which can then be readily used with Bokeh. A notebook showing it off can be found at:
http://nbviewer.ipython.org/urls/gist.githubusercontent.com/RutgerK/e707239e1f82b3287a5d/raw/Bokeh_test

Most code comes from Sarah’s example. Its using Dutch census data, but it should work with any other datasets as well, like Natural Earth for example (http://www.naturalearthdata.com/).

@Sarah, does your code work well for MultiPolygons? I dont see you inserting a ‘NaN’ between the separate parts in utils.py, wouldn’t that mean that the end of a part gets connected with a line to the start of another?

For some people GeoPandas might be an interesting module to combine with Bokeh, but on Windows its a pain to compile the dependencies, and there’s no Conda package.

Regards,
Rutger

On Tuesday, May 19, 2015 at 6:55:04 AM UTC+2, Sarah Bird wrote:

Hi Martin,

I’m sorry I don’t have time to give you a more detailed answer. In my case I very crudely pulled the coordinates out of geojson Polygons (http://geojson.org/geojson-spec.html#id4) & Multipolygons (http://geojson.org/geojson-spec.html#id7). You can see the code here: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/main/utils.py#L43

The core bokeh examples (http://bokeh.pydata.org/en/latest/docs/gallery/choropleth.html & http://bokeh.pydata.org/en/latest/docs/gallery/texas.html) have data from a different source where it was slightly easier to pull it out.

I know that having better mapping support is something people want, but it’s not super easy just yet.

Best,

Bird

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%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 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/c8836ac0-ea84-4e7f-8300-f7cfb7f35a59%40continuum.io.

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

I started a new issue here: https://github.com/bokeh/bokeh/issues/2321

···

On Wed, May 20, 2015 at 3:36 AM, Sarah Bird [email protected] wrote:

Hi Rutger,

Thanks for this.

“I also stumbled on a bug, my code plots the parts of multipolygons correctly (for as far as i can tell), but it does not plot inner rings (holes) correctly.”

There is currently no support for this in Bokeh. I have mentioned it to the core team and they’re keen to see that feature be implemented. I’m hoping to work on it over the coming month or so.

Best,

Bird

On Wed, May 20, 2015 at 3:04 AM, Rutger Kassies [email protected] wrote:

Off course, but i noticed they changed the format of the data a little, but here is an older version which still works:
http://www.cbs.nl/nl-NL/menu/themas/dossiers/nederland-regionaal/links/2012-wijk-en-buurtkaart-2009-3-el.htm

I used census data of 2011 which i had downloaded years ago, the link above contains data for 2009. The archive which you download contains three Shapefiles of different administrative levels. I used the highest one ‘gem_2009_gn3.shp’, which is at municipality level (gemeente). The three attributes i used are the total number of inhabitants, and broken down to male/female. The coordinate system of the Shapefile is Rijksdriehoek (RD new): http://spatialreference.org/ref/epsg/amersfoort-rd-new/

It might be necessary to convert the attributes of the Shapefile to UTF-8, i had to in Python 3. I did this by opening the Shapefile in QGIS, and choosing ‘save as’, and then select ‘utf-8’ as the ‘system’ in the save-dialog.

I also stumbled on a bug, my code plots the parts of multipolygons correctly (for as far as i can tell), but it does not plot inner rings (holes) correctly. It draws a line from the outer to the inner ring. I did a test where i also separate the inner ring with a ‘NaN’, but then it plots as a normal polygon, instead of a hole. I will try to come up with a solution, but the format of Bokeh’s Patches is not entirely clear to me. I would be interested in an example of Bokeh plotting Multipolygons with holes.

Regards,
Rutger

On Tuesday, May 19, 2015 at 8:02:47 PM UTC+2, Sarah Bird wrote:

Rutger is it possible to share that shape file. I’d love to play with your code in more detail.

On Tue, May 19, 2015 at 10:57 AM, Sarah Bird [email protected] wrote:

Hi Rutger,

Thanks for posting this, that’s great. I did a hack job on multipolygons and didn’t put in a NaN in the final version (I think it was something wierd around hover on Patches not working so I didn’t want to do them for now). Luckily for me this hack is ok for Africa. You can’t see it clearly on the notebooks (http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb) but Angola is a multipolygon which I’ve joined like this and it does put a random line in, it’s just not v. noticeable.

There definitely was one in there at some point and I’ve forgotten why I took it out. I’m working on turning this demo into an example that’ll live in bokeh’s examples, so I will definitely make sure I do that properly then.

Thanks again for posting your code. v. helpful.

Bird

On Tue, May 19, 2015 at 12:58 AM, [email protected] wrote:

Hey,

After seeing Sarah’s talk, i had a go at it myself, just trying to replicate the result with a different data source. I made a Python function (getAttributes) which converts an OGR (GDAL) vector data source to a Pandas DataFrame, which can then be readily used with Bokeh. A notebook showing it off can be found at:
http://nbviewer.ipython.org/urls/gist.githubusercontent.com/RutgerK/e707239e1f82b3287a5d/raw/Bokeh_test

Most code comes from Sarah’s example. Its using Dutch census data, but it should work with any other datasets as well, like Natural Earth for example (http://www.naturalearthdata.com/).

@Sarah, does your code work well for MultiPolygons? I dont see you inserting a ‘NaN’ between the separate parts in utils.py, wouldn’t that mean that the end of a part gets connected with a line to the start of another?

For some people GeoPandas might be an interesting module to combine with Bokeh, but on Windows its a pain to compile the dependencies, and there’s no Conda package.

Regards,
Rutger

On Tuesday, May 19, 2015 at 6:55:04 AM UTC+2, Sarah Bird wrote:

Hi Martin,

I’m sorry I don’t have time to give you a more detailed answer. In my case I very crudely pulled the coordinates out of geojson Polygons (http://geojson.org/geojson-spec.html#id4) & Multipolygons (http://geojson.org/geojson-spec.html#id7). You can see the code here: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/main/utils.py#L43

The core bokeh examples (http://bokeh.pydata.org/en/latest/docs/gallery/choropleth.html & http://bokeh.pydata.org/en/latest/docs/gallery/texas.html) have data from a different source where it was slightly easier to pull it out.

I know that having better mapping support is something people want, but it’s not super easy just yet.

Best,

Bird

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%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 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/c8836ac0-ea84-4e7f-8300-f7cfb7f35a59%40continuum.io.

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

Just wanted to say that I am experimenting too with the creation of a map of london and the hover tool has problems.

I have 1264 areas to draw and:

  • If I create the dict for ALL of the areas that will be used for the hover tool, the tooltips are wrong, you find areas that are supposed to be in the north in the south and viceversa

  • If I limit the areas to a 15, but using the same functions, the tooltips are correct…

anyone had problems with the hover tool with choropleths ?

···

On Wednesday, 20 May 2015 12:32:16 UTC+1, Sarah Bird wrote:

I started a new issue here: https://github.com/bokeh/bokeh/issues/2321

On Wed, May 20, 2015 at 3:36 AM, Sarah Bird [email protected] wrote:

Hi Rutger,

Thanks for this.

“I also stumbled on a bug, my code plots the parts of multipolygons correctly (for as far as i can tell), but it does not plot inner rings (holes) correctly.”

There is currently no support for this in Bokeh. I have mentioned it to the core team and they’re keen to see that feature be implemented. I’m hoping to work on it over the coming month or so.

Best,

Bird

On Wed, May 20, 2015 at 3:04 AM, Rutger Kassies [email protected] wrote:

Off course, but i noticed they changed the format of the data a little, but here is an older version which still works:
http://www.cbs.nl/nl-NL/menu/themas/dossiers/nederland-regionaal/links/2012-wijk-en-buurtkaart-2009-3-el.htm

I used census data of 2011 which i had downloaded years ago, the link above contains data for 2009. The archive which you download contains three Shapefiles of different administrative levels. I used the highest one ‘gem_2009_gn3.shp’, which is at municipality level (gemeente). The three attributes i used are the total number of inhabitants, and broken down to male/female. The coordinate system of the Shapefile is Rijksdriehoek (RD new): http://spatialreference.org/ref/epsg/amersfoort-rd-new/

It might be necessary to convert the attributes of the Shapefile to UTF-8, i had to in Python 3. I did this by opening the Shapefile in QGIS, and choosing ‘save as’, and then select ‘utf-8’ as the ‘system’ in the save-dialog.

I also stumbled on a bug, my code plots the parts of multipolygons correctly (for as far as i can tell), but it does not plot inner rings (holes) correctly. It draws a line from the outer to the inner ring. I did a test where i also separate the inner ring with a ‘NaN’, but then it plots as a normal polygon, instead of a hole. I will try to come up with a solution, but the format of Bokeh’s Patches is not entirely clear to me. I would be interested in an example of Bokeh plotting Multipolygons with holes.

Regards,
Rutger

On Tuesday, May 19, 2015 at 8:02:47 PM UTC+2, Sarah Bird wrote:

Rutger is it possible to share that shape file. I’d love to play with your code in more detail.

On Tue, May 19, 2015 at 10:57 AM, Sarah Bird [email protected] wrote:

Hi Rutger,

Thanks for posting this, that’s great. I did a hack job on multipolygons and didn’t put in a NaN in the final version (I think it was something wierd around hover on Patches not working so I didn’t want to do them for now). Luckily for me this hack is ok for Africa. You can’t see it clearly on the notebooks (http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb) but Angola is a multipolygon which I’ve joined like this and it does put a random line in, it’s just not v. noticeable.

There definitely was one in there at some point and I’ve forgotten why I took it out. I’m working on turning this demo into an example that’ll live in bokeh’s examples, so I will definitely make sure I do that properly then.

Thanks again for posting your code. v. helpful.

Bird

On Tue, May 19, 2015 at 12:58 AM, [email protected] wrote:

Hey,

After seeing Sarah’s talk, i had a go at it myself, just trying to replicate the result with a different data source. I made a Python function (getAttributes) which converts an OGR (GDAL) vector data source to a Pandas DataFrame, which can then be readily used with Bokeh. A notebook showing it off can be found at:
http://nbviewer.ipython.org/urls/gist.githubusercontent.com/RutgerK/e707239e1f82b3287a5d/raw/Bokeh_test

Most code comes from Sarah’s example. Its using Dutch census data, but it should work with any other datasets as well, like Natural Earth for example (http://www.naturalearthdata.com/).

@Sarah, does your code work well for MultiPolygons? I dont see you inserting a ‘NaN’ between the separate parts in utils.py, wouldn’t that mean that the end of a part gets connected with a line to the start of another?

For some people GeoPandas might be an interesting module to combine with Bokeh, but on Windows its a pain to compile the dependencies, and there’s no Conda package.

Regards,
Rutger

On Tuesday, May 19, 2015 at 6:55:04 AM UTC+2, Sarah Bird wrote:

Hi Martin,

I’m sorry I don’t have time to give you a more detailed answer. In my case I very crudely pulled the coordinates out of geojson Polygons (http://geojson.org/geojson-spec.html#id4) & Multipolygons (http://geojson.org/geojson-spec.html#id7). You can see the code here: https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/main/utils.py#L43

The core bokeh examples (http://bokeh.pydata.org/en/latest/docs/gallery/choropleth.html & http://bokeh.pydata.org/en/latest/docs/gallery/texas.html) have data from a different source where it was slightly easier to pull it out.

I know that having better mapping support is something people want, but it’s not super easy just yet.

Best,

Bird

On Mon, May 18, 2015 at 4:31 AM, Martin Frlin [email protected] wrote:

Thank you for the pointers in the code but could you also tell me some keywords to google the original data I need?

For example in the table we see that there are a lot of xs and ys which are some kind of coordinates. I believe glyphs representing each country in Africa are constructed from those coordinates. Could you tell me what those are and how do I find/construct them?

2015-05-18 2:36 GMT+02:00 Sarah Bird [email protected]:

Hi Martin,

All the code for the talk is available: https://github.com/birdsarah/pycon_2015_bokeh_talk/.

In particular, the map construction is here:

https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/washmap_static.py#L38

and the function construct_map:
https://github.com/birdsarah/pycon_2015_bokeh_talk/blob/master/washmap/washmap/water_map.py#L24

but the hard thing is getting the data in the right shape…you can browse around to see all the code that does that, but you can see the table here:
http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb

Hope that helps,

Sarah Bird

On Sat, May 16, 2015 at 1:04 PM, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.

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/21a6d8aa-b1fc-464b-b21e-e86f01ccab94%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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BEr%2BdR6Nu5ewwc%3DvPfLx5D-LM6H%2BvoxUbPn%2Bd1%2Bnkyu4Wi-Jw%40mail.gmail.com.

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/CAMgiKoyuKncevt14dD9V_Zqf9LvPhAVqyGSPjABRE%2BAAhE6uPA%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 the Google Groups “Bokeh Discussion - Public” group.

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

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/c8836ac0-ea84-4e7f-8300-f7cfb7f35a59%40continuum.io.

For creating custom map, download the geojson data for a country and then you could use the json with bokeh for creating custom map. Following is the code for creating custom map for china.

china.json (53.2 KB)

···

import json

from bokeh.plotting import *

with open(“china.json”, ‘r’) as f:

datastore = json.load(f)

maps={}

for itr in range(0,len(datastore[‘features’])):

name=datastore[‘features’][itr][‘properties’][‘name’]

location=datastore[‘features’][itr][‘geometry’][‘coordinates’][0]

maps[name]=location

p = figure(title=“China”,toolbar_location=“left”, plot_width=1000, plot_height=600, name=“plot”)

for key in maps.keys():

state_xs=[x[0] for x in maps[key]]

state_ys=[x[1] for x in maps[key]]

p.patch(state_xs, state_ys, fill_alpha=0.0,line_color=“black”, line_width=1.5)

show§


On Sunday, May 17, 2015 at 11:36:38 PM UTC+5:30, [email protected] wrote:

I’ve searched but were unable to find how do I create a map for my country.

The example US and Texas maps are already made and you only need to import them, but how do I make my own maps?

I’ve also seen example with the map of Africa https://github.com/birdsarah/pycon_2015_bokeh_talk but I am also lost on how that map was constructed.

Any help appreciated.