def process_crs(crs):
try:<EOL><INDENT>import cartopy.crs as ccrs<EOL>import geoviews as gv <EOL>import pyproj<EOL><DEDENT>except:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>if crs is None:<EOL><INDENT>return ccrs.PlateCarree()<EOL><DEDENT>if isinstance(crs, basestring) and crs.lower().startswith('<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>crs = ccrs.epsg(crs[<NUM_LIT:5>:].lstrip().rstrip())<EOL><DEDENT>except:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>elif isinstance(crs, int):<EOL><INDENT>crs = ccrs.epsg(crs)<EOL><DEDENT>elif isinstance(crs, (basestring, pyproj.Proj)):<EOL><INDENT>try:<EOL><INDENT>crs = proj_to_cartopy(crs)<EOL><DEDENT>except:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>elif not isinstance(crs, ccrs.CRS):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return crs<EOL>
Parses cartopy CRS definitions defined in one of a few formats:

  1. EPSG codes:   Defined as string of the form "EPSG: {code}" or an integer
  2. proj.4 string: Defined as string of the form "{proj.4 string}"
  3. cartopy.crs.CRS instance
  4. None defaults to crs.PlateCaree