plot maps

I am producing a plot similar to texas.py for MA, but the quality of the borders of the map is not very good: can I use shapefiles instead of the default maps on Bokeh (also for plotting zip codes instead of counties, etc).

Thanks!

Urbano

Hi Urbano,

The sample data included with Bokeh was really just intended for demonstration. I scraped it off a Google spreadsheet doc somewhere, and cannot in any way vouch for its quality. The short answer to your question is "yes" you can use shapefiles, but the longer answer is that there is no built-in support for dealing with shapefiles. You will have to convert the data to the simple format that Bokeh understands. (As an aside: it would be great to have a contribution that made dealing with various GIS formats easier).

The format that Bokeh expects for patches is a "list of lists" of points. So something like:

  xs = [ [patch0 x-coords], [patch1 x-coords], ... ]
  ys = [ [patch1 y-coords], [patch1 y-coords], ... ]

Note that if a patch is comprised of multiple polygons, this is currently expressed by putting NaN values in the sublists. So, the task is basically to convert whatever form of polygon data you have to this format, and then Bokeh can display it. Note also that Bokeh doesn't currently support any kind of GIS projections yet (though this is planned).

Let me know if this helps, or if there is any additional information I can provide to assist.

Thanks,

Bryan

···

On Jan 16, 2015, at 9:30 AM, Urbano França <[email protected]> wrote:

I am producing a plot similar to texas.py for MA, but the quality of the borders of the map is not very good: can I use shapefiles instead of the default maps on Bokeh (also for plotting zip codes instead of counties, etc).

Thanks!

Urbano

--
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/f4a96624-a671-4b0f-8e53-be746f27e0ac%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Brian, can you elaborate a bit more on this (using patches to display complex shape file data is also an issue which I am currently wrestling with) - I wasn’t so clear on the use of NaN’s?
Also, in particular, I am curious if patches have the capability to have holes in them (and if not, if this will be added)? For example, in Matplotlib.patches.patches() function, you can plot a patch, with an outer border, and also inner negative space (holes). This is essentially recognised in a standard way where the outer points are listed in a specific direction (clockwise) while the inner space (hole/s) are denoted by anticlockwise ordered points.

Ps. Thanks to you and the dev. team for the great work and excellent software, and I am very happy to see so many helpful Youtube videos on Bokeh which are a big help!

···

On 24 Jan 2015, at 20:11, Bryan Van de Ven <[email protected]> wrote:

Hi Urbano,

The sample data included with Bokeh was really just intended for demonstration. I scraped it off a Google spreadsheet doc somewhere, and cannot in any way vouch for its quality. The short answer to your question is "yes" you can use shapefiles, but the longer answer is that there is no built-in support for dealing with shapefiles. You will have to convert the data to the simple format that Bokeh understands. (As an aside: it would be great to have a contribution that made dealing with various GIS formats easier).

The format that Bokeh expects for patches is a "list of lists" of points. So something like:

  xs = [ [patch0 x-coords], [patch1 x-coords], ... ]
  ys = [ [patch1 y-coords], [patch1 y-coords], ... ]

Note that if a patch is comprised of multiple polygons, this is currently expressed by putting NaN values in the sublists. So, the task is basically to convert whatever form of polygon data you have to this format, and then Bokeh can display it. Note also that Bokeh doesn't currently support any kind of GIS projections yet (though this is planned).

Let me know if this helps, or if there is any additional information I can provide to assist.

Thanks,

Bryan

On Jan 16, 2015, at 9:30 AM, Urbano França <[email protected]> wrote:

I am producing a plot similar to texas.py for MA, but the quality of the borders of the map is not very good: can I use shapefiles instead of the default maps on Bokeh (also for plotting zip codes instead of counties, etc).

Thanks!

Urbano

--
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/f4a96624-a671-4b0f-8e53-be746f27e0ac%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/A2DF0D83-D9A8-46AB-94CD-F4AE36B5711F%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Ben,

Yes I should have been more clear about the use of NaNs. A bokeh patch is (or can be) a "multi polygon". Consider the state of Texas. Conceptually you want one single glyph to represent this one piece of data, but the region that defines "Texas" is comprised of more that one polygon --- consider Galveston island. For the patches glyph, every "sublist" is a distinct patch, but the patch can have multiple disjoint polygons, and these are indicated by putting all their coordinates in the same sublist, but separated by NaNs where appropriate.

The capability to draw "holes" in polygonal regions is definitely available at the HTML canvas level, and is accomplished exactly how you describe, by stroking the parts of the path in "opposite" directions. It occurs to me that there may not be a way to "spell" this in python. It's worth experimenting, I might be pleasantly surprised that there is already a way, but if not, we should make an issue to makes sure this use-case gets supported.

Thanks,

Bryan

···

On Jan 24, 2015, at 4:15 PM, Ben Laken <[email protected]> wrote:

Hi Brian, can you elaborate a bit more on this (using patches to display complex shape file data is also an issue which I am currently wrestling with) - I wasn’t so clear on the use of NaN’s?
Also, in particular, I am curious if patches have the capability to have holes in them (and if not, if this will be added)? For example, in Matplotlib.patches.patches() function, you can plot a patch, with an outer border, and also inner negative space (holes). This is essentially recognised in a standard way where the outer points are listed in a specific direction (clockwise) while the inner space (hole/s) are denoted by anticlockwise ordered points.

Ps. Thanks to you and the dev. team for the great work and excellent software, and I am very happy to see so many helpful Youtube videos on Bokeh which are a big help!

On 24 Jan 2015, at 20:11, Bryan Van de Ven <[email protected]> wrote:

Hi Urbano,

The sample data included with Bokeh was really just intended for demonstration. I scraped it off a Google spreadsheet doc somewhere, and cannot in any way vouch for its quality. The short answer to your question is "yes" you can use shapefiles, but the longer answer is that there is no built-in support for dealing with shapefiles. You will have to convert the data to the simple format that Bokeh understands. (As an aside: it would be great to have a contribution that made dealing with various GIS formats easier).

The format that Bokeh expects for patches is a "list of lists" of points. So something like:

  xs = [ [patch0 x-coords], [patch1 x-coords], ... ]
  ys = [ [patch1 y-coords], [patch1 y-coords], ... ]

Note that if a patch is comprised of multiple polygons, this is currently expressed by putting NaN values in the sublists. So, the task is basically to convert whatever form of polygon data you have to this format, and then Bokeh can display it. Note also that Bokeh doesn't currently support any kind of GIS projections yet (though this is planned).

Let me know if this helps, or if there is any additional information I can provide to assist.

Thanks,

Bryan

On Jan 16, 2015, at 9:30 AM, Urbano França <[email protected]> wrote:

I am producing a plot similar to texas.py for MA, but the quality of the borders of the map is not very good: can I use shapefiles instead of the default maps on Bokeh (also for plotting zip codes instead of counties, etc).

Thanks!

Urbano

--
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/f4a96624-a671-4b0f-8e53-be746f27e0ac%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/A2DF0D83-D9A8-46AB-94CD-F4AE36B5711F%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/81F0C01D-94DC-46A1-B8B8-67EC65A81FA9%40gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

Thank you for your answer. I’ll play with the patches in the format you mentioned and see if I can get that to work.

Thanks,

U

···

On Saturday, January 24, 2015 at 2:11:48 PM UTC-5, Bryan Van de ven wrote:

Hi Urbano,

The sample data included with Bokeh was really just intended for demonstration. I scraped it off a Google spreadsheet doc somewhere, and cannot in any way vouch for its quality. The short answer to your question is “yes” you can use shapefiles, but the longer answer is that there is no built-in support for dealing with shapefiles. You will have to convert the data to the simple format that Bokeh understands. (As an aside: it would be great to have a contribution that made dealing with various GIS formats easier).

The format that Bokeh expects for patches is a “list of lists” of points. So something like:

    xs = [ [patch0 x-coords], [patch1 x-coords], ... ]

    ys = [ [patch1 y-coords], [patch1 y-coords], ... ]

Note that if a patch is comprised of multiple polygons, this is currently expressed by putting NaN values in the sublists. So, the task is basically to convert whatever form of polygon data you have to this format, and then Bokeh can display it. Note also that Bokeh doesn’t currently support any kind of GIS projections yet (though this is planned).

Let me know if this helps, or if there is any additional information I can provide to assist.

Thanks,

Bryan

On Jan 16, 2015, at 9:30 AM, Urbano França [email protected] wrote:

I am producing a plot similar to texas.py for MA, but the quality of the borders of the map is not very good: can I use shapefiles instead of the default maps on Bokeh (also for plotting zip codes instead of counties, etc).

Thanks!

Urbano


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/f4a96624-a671-4b0f-8e53-be746f27e0ac%40continuum.io.

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

Hi, not sure if there is any way around this but I am having some difficulty working with the hover tool over scatter or circles data when the X and Y ranges are very different.

My Y range is an order of magnitude larger than my X range. It seems that the hover tool will only display within a sub-region of the circle (or scatter) glyphs covered by the equivalent radius in both the x and y dimension. (i.e. although the glyph appears as a circle as it should, the hover tool only appears within a narrow central range of the glyph of within the radius value in both dimensions).

I guess this behaviour is a bug?

Hi,

···

On Mon, Jan 26, 2015 at 1:04 PM, Ben Laken [email protected] wrote:

Hi, not sure if there is any way around this but I am having some difficulty working with the hover tool over scatter or circles data when the X and Y ranges are very different.

My Y range is an order of magnitude larger than my X range. It seems that the hover tool will only display within a sub-region of the circle (or scatter) glyphs covered by the equivalent radius in both the x and y dimension. (i.e. although the glyph appears as a circle as it should, the hover tool only appears within a narrow central range of the glyph of within the radius value in both dimensions).

I guess this behaviour is a bug?

Would you mind submitting some code showing how you construct the plot? I experimented with various configurations of ranges on both axes, glyph size and (non-)overlapping glyphs, and I couldn’t make hover tool work in the described way. Also, what version of bokeh do you use?

Thanks,

Mateusz

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/4AC2D994-6A13-4FA1-A786-D4F739E6582C%40gmail.com.

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

I’m not sure if this helps, but I had a problem with hover and circles (although I was using categorical ranges). Bryan filed an issue after I reported it and it is still open: https://github.com/bokeh/bokeh/issues/624

My workaround was to use blank rectangles on top of my circles and have the hover interact with them. This was fine for me as my data was categorical, so the circles weren’t overlapping. Maybe that wouldn’t work for you, but I just thought I’d mention it. (https://groups.google.com/a/continuum.io/forum/#!searchin/bokeh/circle$20categorical/bokeh/fKIHJqnx9Us/zjp7ji__BrYJ)

···

On Mon, Jan 26, 2015 at 7:15 AM, Mateusz Paprocki [email protected] wrote:

Hi,

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/CANFzp8g–3%3DVeU%3D1UVxGCE2hnrrYp8aZjKnMo_aCtugMt8-wvA%40mail.gmail.com.

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

On Mon, Jan 26, 2015 at 1:04 PM, Ben Laken [email protected] wrote:

Hi, not sure if there is any way around this but I am having some difficulty working with the hover tool over scatter or circles data when the X and Y ranges are very different.

My Y range is an order of magnitude larger than my X range. It seems that the hover tool will only display within a sub-region of the circle (or scatter) glyphs covered by the equivalent radius in both the x and y dimension. (i.e. although the glyph appears as a circle as it should, the hover tool only appears within a narrow central range of the glyph of within the radius value in both dimensions).

I guess this behaviour is a bug?

Would you mind submitting some code showing how you construct the plot? I experimented with various configurations of ranges on both axes, glyph size and (non-)overlapping glyphs, and I couldn’t make hover tool work in the described way. Also, what version of bokeh do you use?

Thanks,

Mateusz

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/4AC2D994-6A13-4FA1-A786-D4F739E6582C%40gmail.com.

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

Hi Ben,

This is a known corner case:

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

A possible immediate workaround: if it is possible for you to set "size" (which specifies screen pixel dimensions) instead of "radius" (which is in data space units) that might allow hit testing to work as expected. Of course, if you need to the circle to scale as the plot area is zoomed, this is not an option.

Longer term, one proposal that might help is to allow the dimension that is used to measure the radius to be configurable:

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

And another possibility is to add a mode where the normal spatial index is not used, and all hit testing is done by "brute force", in screen space. I wouldn't want that to be the default, though, the spatial index is useful for interactivity in many instances.

Bryan

···

On Jan 26, 2015, at 6:04 AM, Ben Laken <[email protected]> wrote:

Hi, not sure if there is any way around this but I am having some difficulty working with the hover tool over scatter or circles data when the X and Y ranges are very different.

My Y range is an order of magnitude larger than my X range. It seems that the hover tool will only display within a sub-region of the circle (or scatter) glyphs covered by the equivalent radius in both the x and y dimension. (i.e. although the glyph appears as a circle as it should, the hover tool only appears within a narrow central range of the glyph of within the radius value in both dimensions).

I guess this behaviour is a bug?

--
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/4AC2D994-6A13-4FA1-A786-D4F739E6582C%40gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Right! I forgot all about that, thanks for reminding about this other possible workaround Sara,

Bryan

···

On Jan 26, 2015, at 9:25 AM, Sarah Bird <[email protected]> wrote:

I'm not sure if this helps, but I had a problem with hover and circles (although I was using categorical ranges). Bryan filed an issue after I reported it and it is still open: https://github.com/bokeh/bokeh/issues/624

My workaround was to use blank rectangles on top of my circles and have the hover interact with them. This was fine for me as my data was categorical, so the circles weren't overlapping. Maybe that wouldn't work for you, but I just thought I'd mention it. (https://groups.google.com/a/continuum.io/forum/#!searchin/bokeh/circle$20categorical/bokeh/fKIHJqnx9Us/zjp7ji__BrYJ)

On Mon, Jan 26, 2015 at 7:15 AM, Mateusz Paprocki <[email protected]> wrote:
Hi,

On Mon, Jan 26, 2015 at 1:04 PM, Ben Laken <[email protected]> wrote:
Hi, not sure if there is any way around this but I am having some difficulty working with the hover tool over scatter or circles data when the X and Y ranges are very different.

My Y range is an order of magnitude larger than my X range. It seems that the hover tool will only display within a sub-region of the circle (or scatter) glyphs covered by the equivalent radius in both the x and y dimension. (i.e. although the glyph appears as a circle as it should, the hover tool only appears within a narrow central range of the glyph of within the radius value in both dimensions).

I guess this behaviour is a bug?

Would you mind submitting some code showing how you construct the plot? I experimented with various configurations of ranges on both axes, glyph size and (non-)overlapping glyphs, and I couldn't make hover tool work in the described way. Also, what version of bokeh do you use?

Thanks,

Mateusz

--
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/4AC2D994-6A13-4FA1-A786-D4F739E6582C%40gmail.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/CANFzp8g--3%3DVeU%3D1UVxGCE2hnrrYp8aZjKnMo_aCtugMt8-wvA%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/CA%2BEr%2BdQk9MdohqswK10GOodLaJWHBP1u%3DiL-j0%2BcBk1Fhto8Vg%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.