holoviz / geoviews

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

Overlaying Land on NorthPolarProjection Error #271

Closed ahuang11 closed 5 years ago

ahuang11 commented 5 years ago
import xarray as xr
import hvplot.xarray
import cartopy.crs as ccrs

xr.tutorial.open_dataset('air_temperature')['air'].hvplot(groupby='time', geo=True, projection=ccrs.NorthPolarStereo()) * gv.feature.land

DataError: Supplied data does not contain specified dimensions, the following dimensions were not found: ['Longitude', 'Latitude']

Works with Robinson, PlateCarreee, Mercator, and probably more, but not with Polar/Lambert Conformal

ahuang11 commented 5 years ago

Nevermind works with {'geoviews': '1.6.0', 'holoviews': '1.11.0.post4+gc80f60fc6-dirty', 'hvplot': '0.3.0a7.post2+g73d8f28', 'xarray': '0.11.1'}

philippjfr commented 5 years ago

Yes, I meant to release hvplot 0.3 before I went on a break. Hoping to do it this weekend now.

ahuang11 commented 5 years ago

Actually if you import geopandas, this breaks:

import xarray as xr
import geopandas as gpd
import holoviews as hv
import geoviews as gv
import hvplot.xarray
import cartopy.crs as ccrs
hv.extension('bokeh')
r = hv.renderer('bokeh')

xr.tutorial.open_dataset('air_temperature')['air'].hvplot(groupby='time', geo=True, projection=ccrs.NorthPolarStereo()) * gv.feature.land
ahuang11 commented 5 years ago

Workaround:

import xarray as xr
import geopandas as gpd
import holoviews as hv
import geoviews as gv
import hvplot.xarray
import cartopy.crs as ccrs
from cartopy import feature
hv.extension('bokeh')
r = hv.renderer('bokeh')

land_shps = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres')).dissolve('continent')['geometry']
land = gv.Overlay([gv.Shape(shp) for shp in land_shps])

xr.tutorial.open_dataset('air_temperature')['air'].rename({'lon': 'Longitude', 'lat': 'Latitude'}).hvplot(groupby='time', geo=True, projection=ccrs.NorthPolarStereo()) * land
ahuang11 commented 5 years ago
land_shps = gpd.read_file(
    gpd.datasets.get_path('naturalearth_lowres')
)
gv.Polygons(land_shps.dissolve('continent')).opts(projection=ccrs.NorthPolarStereo())

This alone errors