How to use lat/lon for tile dimensions?

Goal:

  • I want to display a world map on a bokeh plot, on which I use lat/lon coordinates (i.e. -90 to +90, and -180 to +180) to display various points over the map.

Problem:

  • Using the predefined 3rd party tiles (Stamen, CartoDB) does not seem to work with this approach, as they work in meters. Hence, the plot y range for example is interpreted as -90 to +90 meters on the earth map, hence the tile is basically showing the area of 180mx360m at location 0,0.
  • On the other hand, zooming out (a lot) will show the map but then my lat/lon points are obviously condensed into the map center.

Questions:

  • Only BBoxTileSource has a flag ‘use_latlon’, to choose between meters or lat/lon. Where is this conversion done? Do I need to provide this logic on my own?

  • Where to find a tile provider (e.g. OSM) that accepts BBOX as argument and returns an appropriate tile?

  • Should it not be THE most basic use case to work with lat/lon on a world map? At least that is what I see on EVERY world map. Meters are used only for scale.

  • Am I completely on a lost track?

Help!

Hi,

The meters system is not scale, it is Web Mercator which is in common use by all major map tile systems, AFAIK. The immediate solution is for you to convert your lat/lon coordinates to Web Mercator (meters) before passing them to Bokeh plotting functions. There is nothing built in to Bokeh to do this, so yes you will need to do it explicitly yourself. There are various libraries (pyproj, cartopy, etc.) that should be helpful with this. Alternatively, this seems to be a relevant SO answer:

  https://stackoverflow.com/questions/25058880/convert-to-web-mercator-with-numpy

A separate question is what can/should be done to make things simpler or easier for Bokeh users. I'm happy to have a discussion about it, but realistically what is needed is a new contributor with a specific interest in improving Bokeh for GIS plotting to join and help support this part of Bokeh.

Thanks,

Bryan

···

On Feb 23, 2018, at 07:23, Artur Scholz <[email protected]> wrote:

Goal:
- I want to display a world map on a bokeh plot, on which I use lat/lon coordinates (i.e. -90 to +90, and -180 to +180) to display various points over the map.

Problem:
- Using the predefined 3rd party tiles (Stamen, CartoDB) does not seem to work with this approach, as they work in meters. Hence, the plot y range for example is interpreted as -90 to +90 meters on the earth map, hence the tile is basically showing the area of 180mx360m at location 0,0.
- On the other hand, zooming out (a lot) will show the map but then my lat/lon points are obviously condensed into the map center.

Questions:
- Only BBoxTileSource has a flag 'use_latlon', to choose between meters or lat/lon. Where is this conversion done? Do I need to provide this logic on my own?
- Where to find a tile provider (e.g. OSM) that accepts BBOX as argument and returns an appropriate tile?
- Should it not be THE most basic use case to work with lat/lon on a world map? At least that is what I see on EVERY world map. Meters are used only for scale.
- Am I completely on a lost track?

Help!

--
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/CALqfExaOAXQt5yZUwSSVhF%2BkW%2B1vzwHPgFUMpMXuaDpwKD9gUw%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Also to answer your question about use_latlon, it it processed on the BokehJS side:

  https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/tiles/bbox_tile_source.ts#L32-L33

I don't actually remember anything at all about BBOxTileSource. It's possible if you configure it with the standard tile provider URLs but also specify use_latlon=True then things will work. But I have no personal experience with BBoxTileSource so I can't say for sure. You can see the configurations that the other tile providers use here:

  https://github.com/bokeh/bokeh/blob/master/bokeh/tile_providers.py

Thanks,

Bryan

···

On Feb 26, 2018, at 12:23, Bryan Van de ven <[email protected]> wrote:

Hi,

The meters system is not scale, it is Web Mercator which is in common use by all major map tile systems, AFAIK. The immediate solution is for you to convert your lat/lon coordinates to Web Mercator (meters) before passing them to Bokeh plotting functions. There is nothing built in to Bokeh to do this, so yes you will need to do it explicitly yourself. There are various libraries (pyproj, cartopy, etc.) that should be helpful with this. Alternatively, this seems to be a relevant SO answer:

  python - Convert to Web Mercator With Numpy - Stack Overflow

A separate question is what can/should be done to make things simpler or easier for Bokeh users. I'm happy to have a discussion about it, but realistically what is needed is a new contributor with a specific interest in improving Bokeh for GIS plotting to join and help support this part of Bokeh.

Thanks,

Bryan

On Feb 23, 2018, at 07:23, Artur Scholz <[email protected]> wrote:

Goal:
- I want to display a world map on a bokeh plot, on which I use lat/lon coordinates (i.e. -90 to +90, and -180 to +180) to display various points over the map.

Problem:
- Using the predefined 3rd party tiles (Stamen, CartoDB) does not seem to work with this approach, as they work in meters. Hence, the plot y range for example is interpreted as -90 to +90 meters on the earth map, hence the tile is basically showing the area of 180mx360m at location 0,0.
- On the other hand, zooming out (a lot) will show the map but then my lat/lon points are obviously condensed into the map center.

Questions:
- Only BBoxTileSource has a flag 'use_latlon', to choose between meters or lat/lon. Where is this conversion done? Do I need to provide this logic on my own?
- Where to find a tile provider (e.g. OSM) that accepts BBOX as argument and returns an appropriate tile?
- Should it not be THE most basic use case to work with lat/lon on a world map? At least that is what I see on EVERY world map. Meters are used only for scale.
- Am I completely on a lost track?

Help!

--
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/CALqfExaOAXQt5yZUwSSVhF%2BkW%2B1vzwHPgFUMpMXuaDpwKD9gUw%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.