geoviews icon indicating copy to clipboard operation
geoviews copied to clipboard

Discontinuous contours

Open PBrockmann opened this issue 5 years ago • 2 comments

How to remove the discontinuity of the contours visible from the documentation ?

image

Is it an issue to solve with a add_cyclic method from cartopy ?

PBrockmann avatar Mar 14 '19 16:03 PBrockmann

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) ?

PBrockmann avatar Mar 14 '19 16:03 PBrockmann

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

image

ahuang11 avatar Apr 05 '19 04:04 ahuang11