geoviews
geoviews copied to clipboard
Discontinuous contours
How to remove the discontinuity of the contours visible from the documentation ?
Is it an issue to solve with a add_cyclic method from cartopy ?
In the same idea to solve circular topology of global maps, with the Bokeh backend, is there a way to duplicate the display (continuous world as for WMTS tiles) ?
Right, add_cyclic method should work. I just copied its concept with xarray concatenation. And also cartopy works better in my own experience when data longitude's range from -180 to 180 rather than 0 to 360.
import numpy as np
import xarray as xr
import holoviews as hv
import geoviews as gv
import geoviews.feature as gf
from cartopy import crs
from geoviews import opts
gv.extension('matplotlib')
gv.output(size=150)
ds = xr.open_dataset('ensemble.nc').load()
ds_strip = ds.isel(longitude=-1)
ds = xr.concat(
[ds,
ds_strip.assign_coords(longitude=ds_strip['longitude'] + 1),
ds_strip.assign_coords(longitude=ds_strip['longitude'] + 1.9)
], 'longitude'
)
ds['longitude'] = ((ds['longitude'] + 180) % 360 - 180)
ds = ds.sortby('longitude')
kdims = ['time', 'longitude', 'latitude']
vdims = ['surface_temperature']
xr_dataset = gv.Dataset(ds, kdims=kdims, vdims=vdims)
xr_dataset.to(gv.FilledContours,['longitude', 'latitude']) * gf.coastline