From c724ee89520091b5ae38ef9719bfc3126604969c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Thu, 5 Oct 2023 08:51:40 +0200 Subject: [PATCH] Back to basic --- hvplot/converter.py | 11 ++++++----- hvplot/tests/testgeo.py | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hvplot/converter.py b/hvplot/converter.py index a2a24894e..d8f31b889 100644 --- a/hvplot/converter.py +++ b/hvplot/converter.py @@ -407,6 +407,7 @@ def __init__( self.dynamic = dynamic self.geo = any([geo, crs, global_extent, projection, project, coastline, features]) self.crs = self._process_crs(data, crs) if self.geo else None + self.output_projection = self.crs self.project = project self.coastline = coastline self.features = features @@ -584,6 +585,8 @@ def __init__( if self.crs and global_extent: plot_opts['global_extent'] = global_extent + if projection: + plot_opts['projection'] = self.output_projection title = title if title is not None else getattr(self, '_title', None) if title is not None: plot_opts['title'] = title @@ -1260,12 +1263,10 @@ def method_wrapper(ds, x, y): obj = method(x, y) obj._dataset = dataset - if self.geo and self.crs != self.output_projection: + if self.crs and self.project: + # Apply projection before rasterizing import geoviews as gv - if isinstance(obj, gv.element.geo._Element): - obj.opts(projection=self.output_projection) - else: - obj = gv.project(obj, projection=self.output_projection) + obj = gv.project(obj, projection=self.output_projection) if not (self.datashade or self.rasterize or self.downsample): layers = self._apply_layers(obj) diff --git a/hvplot/tests/testgeo.py b/hvplot/tests/testgeo.py index 662a2c10d..cde418801 100644 --- a/hvplot/tests/testgeo.py +++ b/hvplot/tests/testgeo.py @@ -140,6 +140,7 @@ def test_geo_with_rasterize(self): rasterize=True, dynamic=False, aggregator="max", + project=True, ) p1 = gv.Points(ds.isel(time=0), kdims=["lon", "lat"], crs=ccrs.PlateCarree())