holoviz / geoviews

Simple, concise geographical visualization in Python
http://geoviews.org
BSD 3-Clause "New" or "Revised" License
596 stars 77 forks source link

Data disappears with rasterize=True #344

Open hdsingh opened 5 years ago

hdsingh commented 5 years ago

Reproducible Example:

import xarray as xr
import hvplot.xarray
import  geoviews as gv
import geoviews.tile_sources as gvts

data = xr.tutorial.open_dataset('air_temperature') 
gvts.OSM * data.air.hvplot.quadmesh(x='lon', y='lat', global_extent=True, rasterize=True,)

produces empty map(it appears for a second though) Screenshot from 2019-07-27 23-20-13

however it works correct without rasterize:

gvts.OSM * data.air.hvplot.quadmesh(x='lon', y='lat', global_extent=True)

Screenshot from 2019-07-27 23-20-15

gv.version: '1.6.2' hvplot.version: '0.4.0'

Same behaviour can be seen with data = xr.tutorial.open_dataset('rasm').

Solution:

Subtracting 360 from longitude solves this: data['lon'] = data['lon'] -360.

(The python way to convert [0-360] to [-180:180] is lon180 = ((lon360 - 180) % 360) - 180).

Should geoviews handle this internally?

philippjfr commented 5 years ago

For now this can be handled by telling hvPlot that it should project the data ahead of time:

data.air.hvplot.quadmesh(x='lon', y='lat', global_extent=True, rasterize=True, project=True)