From 2ddeffb46149ece29f075bf6736047f110f0b4ba Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Thu, 25 Oct 2018 22:14:14 +0100
Subject: [PATCH] Avoid adding holes if there are none
---
geoviews/operation/projection.py | 8 +++++---
geoviews/util.py | 6 ++++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/geoviews/operation/projection.py b/geoviews/operation/projection.py
index 645bdc7c..fe52aa91 100644
--- a/geoviews/operation/projection.py
+++ b/geoviews/operation/projection.py
@@ -132,11 +132,13 @@ def _process_element(self, element):
projected = gpd.GeoDataFrame(projected, columns=element.data.columns)
elif element.interface is MultiInterface:
x, y = element.kdims
- item = element.data[0]
- if isinstance(item, dict) and 'geometry' in item:
+ item = element.data[0] if element.data else None
+ if item is None or (isinstance(item, dict) and 'geometry' in item):
return element.clone(projected, crs=self.p.projection)
projected = [geom_dict_to_array_dict(p, [x.name, y.name]) for p in projected]
- if pd and isinstance(item, pd.DataFrame):
+ if any('holes' in p for p in projected):
+ pass
+ elif pd and isinstance(item, pd.DataFrame):
projected = [pd.DataFrame(p, columns=item.columns) for p in projected]
elif isinstance(item, np.ndarray):
projected = [np.column_stack([p[d.name] for d in element.dimensions()])
diff --git a/geoviews/util.py b/geoviews/util.py
index ac5a3d6c..01ea7337 100644
--- a/geoviews/util.py
+++ b/geoviews/util.py
@@ -97,7 +97,8 @@ def geom_dict_to_array_dict(geom_dict, coord_names=['Longitude', 'Latitude']):
holes = []
for interior in geom.interiors:
holes.append(geom_to_array(interior))
- new_dict['holes'] = [holes]
+ if holes:
+ new_dict['holes'] = [holes]
elif geom.geom_type == 'MultiPolygon':
outer_holes = []
for g in geom:
@@ -105,7 +106,8 @@ def geom_dict_to_array_dict(geom_dict, coord_names=['Longitude', 'Latitude']):
for interior in g.interiors:
holes.append(geom_to_array(interior))
outer_holes.append(holes)
- new_dict['holes'] = outer_holes
+ if any(hs for hs in outer_holes):
+ new_dict['holes'] = outer_holes
return new_dict