holoviz / geoviews

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

Plot contains no data, and coordinate axes are wrong #235

Closed RPrudden closed 5 years ago

RPrudden commented 5 years ago

I have some working code in holoviews which displays a dataset (constructed from an xarray dataset).

(hv_ds.to(hv.Image, ["projection_x_coordinate", 
"projection_y_coordinate"])).redim.range(rainfall=(0,100))

However, when I try to do the equivalent in geoviews the plot does not contain any data. Also, the axes are completely different. I think geoviews is only plotting a small section of the data, but I have no idea why.

import geoviews as gv
(hv_ds.to(gv.Image, ["projection_x_coordinate", 
"projection_y_coordinate"])).redim.range(rainfall=(0,100))

Extra information

The geoviews version also runs considerably slower than the holoviews version - on the order of minutes, rather than seconds. It gave some warnings while it was running:

/opt/conda/lib/python3.6/site-packages/numpy/core/_methods.py:26: RuntimeWarning: invalid value encountered in reduce
  return umr_maximum(a, axis, None, out, keepdims)

I have also tried loading the data from iris, and regridding into latitude/longitude coordinates, but the results were much the same.

jbednar commented 5 years ago

You just need to tell GeoViews what coordinate system your data is in, using the crs parameter accepted by GeoViews objects. Without that declaration, it assumes your data is in PlateCaree, which is clearly not the case here. Maybe pass crs=crs.GOOGLE_MERCATOR (given the size of those coordinates)?

RPrudden commented 5 years ago

Thanks, this helped! I switched to the geoviews Dataset and used

gv_ds = gv.Dataset(xr_ds, crs=cube.coord_system().as_cartopy_crs())

Strangely, the limits of the cartopy CRS seem to be different than in Iris so that part of the data is cut off. The original is in a TransverseMercator coordinate system, but in cartopy it is mapped to OSGB.

But I think this is either an Iris or a dataset issue, rather than geoviews.

ahuang11 commented 5 years ago

You just need to tell GeoViews what coordinate system your data is in, using the crs parameter accepted by GeoViews objects. Without that declaration, it assumes your data is in PlateCaree, which is clearly not the case here. Maybe pass crs=crs.GOOGLE_MERCATOR (given the size of those coordinates)?

I think GeoViews needs its own FAQ about this heh