holoviz-topics / EarthSim

Tools for working with and visualizing environmental simulations.
https://earthsim.holoviz.org
BSD 3-Clause "New" or "Revised" License
65 stars 21 forks source link

Unsupported geometry type 'GeometryCollection' #124

Closed kcpevey closed 6 years ago

kcpevey commented 6 years ago

I'm switching up the formatting/syntax on one of my notebooks and I can't figure out what I'm doing wrong with geoviews. Previously, I was pulling path data from a drawing, adding some additional spoofed data to it and then plotting it. Now I'm just trying to start with all the data together in one df and then plot it. I specify the projection as part of the drawing (in the tile service) which seemed to work before, but now it looks like that might be an issue?

My notebook is a mess, but I'll send it to @philippjfr and maybe we can discuss.

%%opts Overlay [width=700 height=500] 
%%opts Path (cmap=cmap) [color_index='Max_Wind_Speed', colorbar=True]
%%opts Points (size=10 cmap=cmap) [ color_index='Max_Wind_Speed', colorbar=True] 
hv.streams.PlotSize.scale = 2
(gv.WMTS('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}', 
         extents=mesh_extent, crs=coord_system) *\
 datashade(trimesh.edgepaths, aggregator='any') *\
 gv.Path([data_df], vdims=['Pressure','Max_Wind_Speed'], 
         crs=coord_system).redim.range(Max_Wind_Speed=(min_speed,max_speed))) *\
 gvdata.to(gv.Points, kdims=['Longitude', 'Latitude'], vdims=['Pressure','Max_Wind_Speed'], 
           crs=coord_system).redim.range(Max_Wind_Speed=(min_speed,
           max_speed)).opts(plot=dict(tools=['hover']))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
C:\ProgramData\Anaconda3\envs\ers\lib\site-packages\IPython\core\formatters.py in __call__(self, obj, include, exclude)
    968 
    969             if method is not None:
--> 970                 return method(include=include, exclude=exclude)
    971             return None
    972         else:

c:\projects\ers\github\holoviews\master\holoviews\holoviews\core\dimension.py in _repr_mimebundle_(self, include, exclude)
   1229         combined and returned.
   1230         """
-> 1231         return Store.render(self)
   1232 
   1233 

c:\projects\ers\github\holoviews\master\holoviews\holoviews\core\options.py in render(cls, obj)
   1287         data, metadata = {}, {}
   1288         for hook in hooks:
-> 1289             ret = hook(obj)
   1290             if ret is None:
   1291                 continue

c:\projects\ers\github\holoviews\master\holoviews\holoviews\ipython\display_hooks.py in pprint_display(obj)
    270     if not ip.display_formatter.formatters['text/plain'].pprint:
    271         return None
--> 272     return display(obj, raw_output=True)
    273 
    274 

c:\projects\ers\github\holoviews\master\holoviews\holoviews\ipython\display_hooks.py in display(obj, raw_output, **kwargs)
    246     elif isinstance(obj, (HoloMap, DynamicMap)):
    247         with option_state(obj):
--> 248             output = map_display(obj)
    249     elif isinstance(obj, Plot):
    250         output = render(obj)

c:\projects\ers\github\holoviews\master\holoviews\holoviews\ipython\display_hooks.py in wrapped(element)
    140         try:
    141             max_frames = OutputSettings.options['max_frames']
--> 142             mimebundle = fn(element, max_frames=max_frames)
    143             if mimebundle is None:
    144                 return {}, {}

c:\projects\ers\github\holoviews\master\holoviews\holoviews\ipython\display_hooks.py in map_display(vmap, max_frames)
    200         return None
    201 
--> 202     return render(vmap)
    203 
    204 

c:\projects\ers\github\holoviews\master\holoviews\holoviews\ipython\display_hooks.py in render(obj, **kwargs)
     63         renderer = renderer.instance(fig='png')
     64 
---> 65     return renderer.components(obj, **kwargs)
     66 
     67 

c:\projects\ers\github\holoviews\master\holoviews\holoviews\plotting\bokeh\renderer.py in components(self, obj, fmt, comm, **kwargs)
    268         # Bokeh has to handle comms directly in <0.12.15
    269         comm = False if bokeh_version < '0.12.15' else comm
--> 270         return super(BokehRenderer, self).components(obj,fmt, comm, **kwargs)
    271 
    272 

c:\projects\ers\github\holoviews\master\holoviews\holoviews\plotting\renderer.py in components(self, obj, fmt, comm, **kwargs)
    327             plot = obj
    328         else:
--> 329             plot, fmt = self._validate(obj, fmt)
    330 
    331         widget_id = None

c:\projects\ers\github\holoviews\master\holoviews\holoviews\plotting\renderer.py in _validate(self, obj, fmt, **kwargs)
    226         if isinstance(obj, tuple(self.widgets.values())):
    227             return obj, 'html'
--> 228         plot = self.get_plot(obj, renderer=self, **kwargs)
    229 
    230         fig_formats = self.mode_formats['fig'][self.mode]

c:\projects\ers\github\holoviews\master\holoviews\holoviews\plotting\bokeh\renderer.py in get_plot(self_or_cls, obj, doc, renderer)
    153             curdoc().theme = self_or_cls.theme
    154         doc.theme = self_or_cls.theme
--> 155         plot = super(BokehRenderer, self_or_cls).get_plot(obj, renderer)
    156         plot.document = doc
    157         return plot

c:\projects\ers\github\holoviews\master\holoviews\holoviews\plotting\renderer.py in get_plot(self_or_cls, obj, renderer)
    213             init_key = tuple(v if d is None else d for v, d in
    214                              zip(plot.keys[0], defaults))
--> 215             plot.update(init_key)
    216         else:
    217             plot = obj

c:\projects\ers\github\holoviews\master\holoviews\holoviews\plotting\plot.py in update(self, key)
    511     def update(self, key):
    512         if len(self) == 1 and ((key == 0) or (key == self.keys[0])) and not self.drawn:
--> 513             return self.initialize_plot()
    514         item = self.__getitem__(key)
    515         self.traverse(lambda x: setattr(x, '_updated', True))

C:\ProgramData\Anaconda3\envs\ers\lib\site-packages\geoviews-1.5.1.post6+g5ce5f3f-py3.5.egg\geoviews\plotting\bokeh\plot.py in initialize_plot(self, ranges, plot, plots, source)
     82     def initialize_plot(self, ranges=None, plot=None, plots=None, source=None):
     83         opts = {} if isinstance(self, HvOverlayPlot) else {'source': source}
---> 84         fig = super(GeoPlot, self).initialize_plot(ranges, plot, plots, **opts)
     85         if self.geographic and self.show_bounds and not self.overlaid:
     86             from . import GeoShapePlot

c:\projects\ers\github\holoviews\master\holoviews\holoviews\plotting\bokeh\element.py in initialize_plot(self, ranges, plot, plots)
   1404             frame = None
   1405             if self.tabs: subplot.overlaid = False
-> 1406             child = subplot.initialize_plot(ranges, plot, plots)
   1407             if isinstance(element, CompositeOverlay):
   1408                 frame = element.get(key, None)

C:\ProgramData\Anaconda3\envs\ers\lib\site-packages\geoviews-1.5.1.post6+g5ce5f3f-py3.5.egg\geoviews\plotting\bokeh\plot.py in initialize_plot(self, ranges, plot, plots, source)
     82     def initialize_plot(self, ranges=None, plot=None, plots=None, source=None):
     83         opts = {} if isinstance(self, HvOverlayPlot) else {'source': source}
---> 84         fig = super(GeoPlot, self).initialize_plot(ranges, plot, plots, **opts)
     85         if self.geographic and self.show_bounds and not self.overlaid:
     86             from . import GeoShapePlot

c:\projects\ers\github\holoviews\master\holoviews\holoviews\plotting\bokeh\element.py in initialize_plot(self, ranges, plot, plots, source)
    729         self.handles['plot'] = plot
    730 
--> 731         self._init_glyphs(plot, element, ranges, source)
    732         if not self.overlaid:
    733             self._update_plot(key, plot, style_element)

c:\projects\ers\github\holoviews\master\holoviews\holoviews\plotting\bokeh\element.py in _init_glyphs(self, plot, element, ranges, source)
    680         else:
    681             style = self.style[self.cyclic_index]
--> 682             data, mapping, style = self.get_data(element, ranges, style)
    683             current_id = element._plot_id
    684         if source is None:

C:\ProgramData\Anaconda3\envs\ers\lib\site-packages\geoviews-1.5.1.post6+g5ce5f3f-py3.5.egg\geoviews\plotting\bokeh\plot.py in get_data(self, element, ranges, style)
    150         proj = self.projection
    151         if self._project_operation and self.geographic:
--> 152             element = self._project_operation(element, projection=proj)
    153         return super(GeoPlot, self).get_data(element, ranges, style)
    154 

C:\ProgramData\Anaconda3\envs\ers\lib\site-packages\param\parameterized.py in __new__(class_, *args, **params)
   1889         inst = class_.instance()
   1890         inst._set_name(class_.__name__)
-> 1891         return inst.__call__(*args,**params)
   1892 
   1893     def __call__(self,*args,**kw):

c:\projects\ers\github\holoviews\master\holoviews\holoviews\core\operation.py in __call__(self, element, **params)
    161                                 operation=self, kwargs=params)
    162         elif isinstance(element, ViewableElement):
--> 163             processed = self._apply(element)
    164         elif isinstance(element, DynamicMap):
    165             if any((not d.values) for d in element.kdims):

c:\projects\ers\github\holoviews\master\holoviews\holoviews\core\operation.py in _apply(self, element, key)
    119         for hook in self._preprocess_hooks:
    120             kwargs.update(hook(self, element))
--> 121         ret = self._process(element, key)
    122         for hook in self._postprocess_hooks:
    123             ret = hook(self, ret, **kwargs)

C:\ProgramData\Anaconda3\envs\ers\lib\site-packages\geoviews-1.5.1.post6+g5ce5f3f-py3.5.egg\geoviews\operation\projection.py in _process(self, element, key)
     32 
     33     def _process(self, element, key=None):
---> 34         return element.map(self._process_element, self.supported_types)
     35 
     36 

c:\projects\ers\github\holoviews\master\holoviews\holoviews\core\dimension.py in map(self, map_fn, specs, clone)
    692             return deep_mapped
    693         else:
--> 694             return map_fn(self) if applies else self
    695 
    696 

C:\ProgramData\Anaconda3\envs\ers\lib\site-packages\geoviews-1.5.1.post6+g5ce5f3f-py3.5.egg\geoviews\operation\projection.py in _process_element(self, element)
    141             data = {vd.name: path.dimension_values(vd, expanded=False) for vd in path.vdims}
    142             if any(len(vals) > 1 for vals in data.values()):
--> 143                 projected += self._project_path(element, path, data, boundary, geom_type, multi_type)
    144             else:
    145                 projected += self._project_contour(element, path, data, boundary, geom_type, multi_type)

C:\ProgramData\Anaconda3\envs\ers\lib\site-packages\geoviews-1.5.1.post6+g5ce5f3f-py3.5.egg\geoviews\operation\projection.py in _project_path(self, element, path, data, boundary, geom_type, multi_type)
     62             if boundary:
     63                 path = path.intersection(boundary)
---> 64             proj = self.p.projection.project_geometry(path, element.crs)
     65             proj_arr = geom_to_array(proj)
     66         data[xdim.name] = proj_arr[:, 0]

C:\ProgramData\Anaconda3\envs\ers\lib\site-packages\cartopy\crs.py in project_geometry(self, geometry, src_crs)
    178         if not method_name:
    179             raise ValueError('Unsupported geometry '
--> 180                              'type {!r}'.format(geom_type))
    181         return getattr(self, method_name)(geometry, src_crs)
    182 

ValueError: Unsupported geometry type 'GeometryCollection'

:DynamicMap   []
   :Overlay
      .WMTS.I   :WMTS   [Longitude,Latitude]
      .RGB.I    :RGB   [x,y]   (R,G,B,A)
      .Path.I   :Path   [Longitude,Latitude]   (Pressure,Max_Wind_Speed)
      .Points.I :Points   [Longitude,Latitude]   (Pressure,Max_Wind_Speed)
philippjfr commented 6 years ago

Suspect it's to do with some recent changes to projecting of paths. Probably don't need the whole notebook but if you could provide the contents of data_df that would be very helpful.

philippjfr commented 6 years ago

This is down to the wrong projection having been specified, coord_system is defined as PlateCarree in the notebook when it should be GOOGLE_MERCATOR.

kcpevey commented 6 years ago

Aha! I saw and changed the projection for gvdata, but I didn't catch the gv.Path one too! Silly mistake. Thanks!

philippjfr commented 6 years ago

Hopefully with the new warning it'll be easier to catch this kind of thing.

kcpevey commented 6 years ago

Yes, I definitely think it will!