diff --git a/hvplot/tests/testutil.py b/hvplot/tests/testutil.py index 704b6e7f3..6c72bb672 100644 --- a/hvplot/tests/testutil.py +++ b/hvplot/tests/testutil.py @@ -11,7 +11,7 @@ from hvplot.util import ( check_crs, is_list_like, process_crs, process_xarray, - _convert_col_names_to_str, + _convert_col_names_to_str ) @@ -287,7 +287,10 @@ def test_check_crs(): 4326, "epsg:4326", "EPSG: 4326", -]) + 'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]]', + # Created with pyproj.CRS("EPSG:3857").to_wkt() + 'PROJCRS["WGS 84 / Pseudo-Mercator",BASEGEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]],CONVERSION["Popular Visualisation Pseudo-Mercator",METHOD["Popular Visualisation Pseudo Mercator",ID["EPSG",1024]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["Web mapping and visualisation."],AREA["World between 85.06°S and 85.06°N."],BBOX[-85.06,-180,85.06,180]],ID["EPSG",3857]]' +], ids=lambda x: str(x)[:20]) def test_process_crs(input): pytest.importorskip("pyproj") ccrs = pytest.importorskip("cartopy.crs") @@ -295,6 +298,13 @@ def test_process_crs(input): assert isinstance(crs, ccrs.CRS) +def test_process_crs_rasterio(): + pytest.importorskip("pyproj") + rcrs = pytest.importorskip("rasterio.crs") + ccrs = pytest.importorskip("cartopy.crs") + input = rcrs.CRS.from_epsg(4326).to_wkt() + crs = process_crs(input) + assert isinstance(crs, ccrs.CRS) def test_process_crs_raises_error(): pytest.importorskip("pyproj") diff --git a/hvplot/util.py b/hvplot/util.py index 83043c8f2..394b102d5 100644 --- a/hvplot/util.py +++ b/hvplot/util.py @@ -117,7 +117,6 @@ def proj_to_cartopy(proj): a cartopy.crs.Projection object """ - import cartopy import cartopy.crs as ccrs try: from osgeo import osr @@ -200,7 +199,7 @@ def proj_to_cartopy(proj): if cl.__name__ == 'Mercator': kw_proj.pop('false_easting', None) kw_proj.pop('false_northing', None) - if Version(cartopy.__version__) < Version('0.15'): + if "scale_factor" in kw_proj: kw_proj.pop('latitude_true_scale', None) elif cl.__name__ == 'Stereographic': kw_proj.pop('scale_factor', None)