def check_crs(crs):
import pyproj<EOL>if isinstance(crs, pyproj.Proj):<EOL><INDENT>out = crs<EOL><DEDENT>elif isinstance(crs, dict) or isinstance(crs, basestring):<EOL><INDENT>try:<EOL><INDENT>out = pyproj.Proj(crs)<EOL><DEDENT>except RuntimeError:<EOL><INDENT>try:<EOL><INDENT>out = pyproj.Proj(init=crs)<EOL><DEDENT>except RuntimeError:<EOL><INDENT>out = None<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>out = None<EOL><DEDENT>return out<EOL>
Checks if the crs represents a valid grid, projection or ESPG string.

(Code copied from https://github.com/fmaussion/salem)

Examples
--------
>>> p = check_crs('+units=m +init=epsg:26915')
>>> p.srs
'+units=m +init=epsg:26915 '
>>> p = check_crs('wrong')
>>> p is None
True
Returns
-------
A valid crs if possible, otherwise None