import iris import numpy as np import holoviews as hv import geoviews as gv import geoviews.feature as gf from cartopy import crs hv.notebook_extension()
package provides a library of Element types which make it very easy to plot data on various geographic projections. Depending on the type of data, the plotting code will automatically infer the correct
and a default output
%%output size=400 features = hv.Overlay([gf.land, gf.ocean, gf.rivers, gf.lakes, gf.borders, gf.coastline]) features
The Bokeh backend currently only supports one output projection (web Mercator), but with the matplotlib backend you can choose between any of the available cartopy projections:
projections = [crs.RotatedPole, crs.Mercator, crs.LambertCylindrical, crs.Geostationary, crs.AzimuthalEquidistant, crs.OSGB, crs.EuroPP, crs.Gnomonic, crs.PlateCarree, crs.Mollweide, crs.OSNI, crs.Miller, crs.InterruptedGoodeHomolosine, crs.LambertConformal, crs.SouthPolarStereo, crs.AlbersEqualArea, crs.Orthographic, crs.NorthPolarStereo, crs.Robinson]
can also be used, but currently generate warnings.) We can test the different projections by creating a HoloViews Layout of
elements, each with a different projection:
hv.Layout([gf.coastline.relabel(group=p.__name__)(plot=dict(projection=p())) for p in projections])
WARNING:root:LayoutPlot04069: None is empty, skipping subplot.
To change the output projection for a single HoloViews object, we can use the call method and set the projection as a plot option. In this way we can easily compose plots with different output projections:
%output size=200 (features.relabel(group='Mollweide')(plot=dict(projection=crs.Mollweide())) + features.relabel(group='Geostationary')(plot=dict(projection=crs.Geostationary())))
Setting the output projection in this way will currently work only with the Matplotlib backend, because Bokeh only supports web Mercator output, but both backends can use incoming data in any of the supported projections, via the
parameter of most GeoViews objects.