Repository: holoviz/hvplot

Issue:
EPSG codes are failing in `process_crs`
#### ALL software version info

```python
hvplot.__version__ = '0.9.2' 
geoviews.__version__ = '1.11.1' 
rasterio.__version__ = '1.3.9' 
xarray.__version__ = '2024.3.0' 
cartopy.__version__ = '0.22.0' 
pyproj.__version__ = '3.6.1' 
```
#### Description of expected behavior

`process_crs` should work for all EPSG codes. This works when using cartopy.crs directly:

```python
import cartopy.crs as ccrs

ccrs.epsg(6933)
```

I think this was introduced in #1139 

#### Complete, minimal, self-contained example code that reproduces the issue

```python
from hvplot.util import preprocess_crs

preprocess_crs(6933)
```
#### Stack traceback and/or browser JavaScript console output

```python-traceback
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
Exception: Unknown projection cea

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
Cell In[64], line 3
      1 from hvplot.util import process_crs
----> 3 process_crs(6933)

File [/srv/conda/envs/notebook/lib/python3.11/site-packages/hvplot/util.py:288](https://hub.openveda.cloud/srv/conda/envs/notebook/lib/python3.11/site-packages/hvplot/util.py#line=287), in process_crs(crs)
    285     except Exception as e:
    286         errors.append(e)
--> 288 raise ValueError(
    289     "Projection must be defined as a EPSG code, proj4 string, "
    290     "WKT string, cartopy CRS, pyproj.Proj, or pyproj.CRS."
    291 ) from Exception(*errors)

ValueError: Projection must be defined as a EPSG code, proj4 string, WKT string, cartopy CRS, pyproj.Proj, or pyproj.CRS.
```

#### Screenshots or screencasts of the bug in action

- [x] I may be interested in making a pull request to address this



Discussion:
I will have a PR up shortly


Resolving patch:
diff --git a/hvplot/util.py b/hvplot/util.py
--- a/hvplot/util.py
+++ b/hvplot/util.py
@@ -303,14 +303,24 @@ def process_crs(crs):
         crs = crs.to_wkt()
 
     errors = []
-    if isinstance(crs, (str, int)):  # epsg codes
+    if isinstance(crs, (str, int, pyproj.Proj)):
+        wkt = crs
+        if isinstance(crs, (str, int)):  # epsg codes
+            try:
+                wkt = pyproj.CRS.from_epsg(crs).to_wkt()
+            except Exception as e:
+                errors.append(e)
         try:
-            crs = pyproj.CRS.from_epsg(crs).to_wkt()
+            return proj_to_cartopy(wkt)  # should be all proj4 or wkt strings
         except Exception as e:
             errors.append(e)
-    if isinstance(crs, (str, pyproj.Proj)):  # proj4/wkt strings
+
+    if isinstance(crs, (str, int)):
+        if isinstance(crs, str):
+            # pyproj does not expect epsg to be prefixed with `EPSG:`
+            crs = crs.upper().replace('EPSG:', '').strip()
         try:
-            return proj_to_cartopy(crs)
+            return ccrs.epsg(crs)
         except Exception as e:
             errors.append(e)
 


Test patch:
diff --git a/hvplot/tests/testutil.py b/hvplot/tests/testutil.py
--- a/hvplot/tests/testutil.py
+++ b/hvplot/tests/testutil.py
@@ -261,6 +261,9 @@ def test_check_crs():
     [
         '+init=epsg:26911',
         'PlateCarree',
+        'epsg:6933',
+        6933,
+        'EPSG: 6933',
     ],
 )
 def test_process_crs(input):