I'm trying to create a CRS from a geopandas CRS, and I'm getting a weird error:
As an example:

(I know it's using a string to create the CRS but it feels a bit like the globe error is a bug which is why I'm posting this, since IIRC that's an optional parameter)
(or I guess more generally, what's the right way to create a cartopy CRS using a rasterio / geopandas CRS object?)
ping
Changed the title because really that's the main goal here - I'm trying to read in TIFF files with either rasterio or geopandas (which reads in a CRS as a rasterio CRS), and I'd like to do plotting with cartopy if possible. However I can't for the life of me figure out how to turn the rasterio CRS into something I can use with cartopy...
I don't know much about it really, but since your currently alone on this... the CRS class is a Cython class defined with cdef class CRS:. I'm not really sure these are designed to be instantiated directly in Python code, in fact the class is defined in _crs.pyx (note the leading underscore indicating private API) and only imported into crs.py so that subclasses can inherit from it. @pelson will be able to provide more useful information.
Hmm, interesting. Thanks for raising @choldgraf. The CRS object is indeed documented, and available at http://scitools.org.uk/cartopy/docs/v0.15/crs/index.html#cartopy.crs.CRS. Be aware though, you are constructing a CRS - not a projection. That means you aren't able to produce a map with it, and you will find a number of places when CRSes can't be used directly as the coordinate system of data (e.g. imshow, but plot & text are fine).
Given the above caveat, and the fact that I needed to make a code change to get it to work, I can't recommend creating CRSes directly in this way. We definitely want to be able to create projections from proj4 strings, but we aren't there yet. #153 relates.
Perhaps we need to add some detail to the docs to state that it is not recommended to create CRSes directly...
FWIW, the changes I needed to make were:
diff --git a/lib/cartopy/_crs.pxd b/lib/cartopy/_crs.pxd
index fab9ab4..1cf0ea8 100644
--- a/lib/cartopy/_crs.pxd
+++ b/lib/cartopy/_crs.pxd
@@ -29,5 +29,6 @@ cdef class CRS:
cdef projPJ proj4
cdef readonly proj4_init
cdef proj4_params
+ cdef globe
cpdef is_geodetic(self)
And I was then able to construct a CRS with:
# The equivalent of ccrs.PlateCarree()...? not quite
pc = ccrs.CRS({'a': 57.29577951308232, 'ellps': 'WGS84', 'lon_0': 0.0, 'proj': 'eqc'})
It is worth cross-referencing #153 here, as I think the question ultimately comes down to: "Can I make a cartopy CRS from a proj4 string?".
There has been some movement on this recently, with #813 being a really positive step in the right direction.
I'd like to add on to this that this is something I'd like to make easier with the xarray library and other projection-heavy libraries (satpy, metpy, etc). I started https://github.com/pydata/xarray/issues/2288 to hopefully find a way to easily convert between different libraries implementations.
I haven't had much time to work on it but I do have a geoxarray package that I started (https://github.com/geoxarray/geoxarray) that in the future will probably use the pycrs library: https://github.com/karimbahgat/PyCRS
I was hoping to add some conversion functions to pycrs for converting to/from rasterio and cartopy CRS objects. CC'ing @karimbahgat
Most helpful comment
I'd like to add on to this that this is something I'd like to make easier with the xarray library and other projection-heavy libraries (satpy, metpy, etc). I started https://github.com/pydata/xarray/issues/2288 to hopefully find a way to easily convert between different libraries implementations.
I haven't had much time to work on it but I do have a geoxarray package that I started (https://github.com/geoxarray/geoxarray) that in the future will probably use the pycrs library: https://github.com/karimbahgat/PyCRS
I was hoping to add some conversion functions to pycrs for converting to/from rasterio and cartopy CRS objects. CC'ing @karimbahgat