Easy geojson with geopandas

Hi,

I’m trying some shortcuts to get choropleth map in Bokeh.

I converted GIS vector to geojson, then load in geopandas:

import geopandas as gpd

df = gpd.read_file(‘sample.geo.json’)

Result from this is pandas dataframe with GIS features. This dataframe has .plot() method which gives matplotlib AxesSubplot object:

ax = df.plot()

fig = mpl.to_bokeh(ax.figure)

show(fig)

This is perhaps as easy as it can get for this task.

However generated HTML file draws this object in pretty basic style and I would like to set some preferences as in regular Bokeh figure, like which tools, dimensions…

Any ideas?

Hi,

Bokeh figure should be in fig = mpl.to_bokeh(ax.figure) with additional methods to user preference.

I would not recommend Bokeh in current shape, as shortcut to Web GIS. It would be easier to develop directly in JS then trying this kind of abstraction (Bokeh does not provide nor it claims to have GIS features for general use)

I would suggest you try “folium” Python package (interface to Leaflet), which is much easier for GIS data and supports geopandas among other things.

Altair/Vega are reasonably supported as well as D3/mpld3.

Cheers,

Dejan

···

On Monday, August 15, 2016 at 7:03:02 PM UTC+2, vedar wrote:

Hi,

I’m trying some shortcuts to get choropleth map in Bokeh.

I converted GIS vector to geojson, then load in geopandas:

import geopandas as gpd

df = gpd.read_file(‘sample.geo.json’)

Result from this is pandas dataframe with GIS features. This dataframe has .plot() method which gives matplotlib AxesSubplot object:

ax = df.plot()

fig = mpl.to_bokeh(ax.figure)

show(fig)

This is perhaps as easy as it can get for this task.

However generated HTML file draws this object in pretty basic style and I would like to set some preferences as in regular Bokeh figure, like which tools, dimensions…

Any ideas?

I would add some additional context. It's been made very easy to add custom extensions to Bokeh. So it is possible to wrap one of the existing JS libraries mentioned below and make them usable directly and naturally in Bokeh documents. The reason this could be valuable is in the case when you want to drive a GIS front end but connect it easily to the pydata stack (numpy, pandas, scikits, etc).

I will add there are longer term plans for a bokeh.geo package but that will be some time off.

Thanks,

Bryan

···

On Aug 19, 2016, at 12:59 PM, [email protected] wrote:

Hi,

Bokeh figure should be in `fig = mpl.to_bokeh(ax.figure)` with additional methods to user preference.

I would not recommend Bokeh in current shape, as shortcut to Web GIS. It would be easier to develop directly in JS then trying this kind of abstraction (Bokeh does not provide nor it claims to have GIS features for general use)

I would suggest you try "folium" Python package (interface to Leaflet), which is much easier for GIS data and supports geopandas among other things.
Altair/Vega are reasonably supported as well as D3/mpld3.

Cheers,
Dejan

On Monday, August 15, 2016 at 7:03:02 PM UTC+2, vedar wrote:
Hi,

I'm trying some shortcuts to get choropleth map in Bokeh.
I converted GIS vector to geojson, then load in geopandas:

import geopandas as gpd
df = gpd.read_file('sample.geo.json')

Result from this is pandas dataframe with GIS features. This dataframe has .plot() method which gives matplotlib AxesSubplot object:

ax = df.plot()
fig = mpl.to_bokeh(ax.figure)
show(fig)

This is perhaps as easy as it can get for this task.

However generated HTML file draws this object in pretty basic style and I would like to set some preferences as in regular Bokeh figure, like which tools, dimensions...

Any ideas?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e02d2cdc-0239-48c1-8a2b-c478f1d5b7c8%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan.

I would add some additional context. It’s been made very easy to add custom extensions to Bokeh.

If you are referring to http://bokeh.pydata.org/en/latest/docs/user_guide/extensions.html#javascript-models-and-views I could not say that it is very easy, but just possible. Possible in a sense that a team of frontend/backend programmers can develop such extension, but not likely possible for single developer to overcome current problem, by writing custom extension. At least for me.

So it is possible to wrap one of the existing JS libraries mentioned below and make them usable directly and naturally in Bokeh documents.

Some example pointers of existing wrappers can be helpful.

I will add there are longer term plans for a bokeh.geo package but that will be some time off.

I expect that would be great.

Thanks