def from_epsg(cls, code): """Make a CRS from an EPSG code Parameters ---------- code : int or str An EPSG code. Strings will be converted to integers. Notes ----- The input code is not validated against an EPSG database. Returns ------- CRS """ obj = cls() obj._crs = _CRS.from_epsg(code) return obj
def from_epsg(cls, code): """Make a CRS from an EPSG code Parameters ---------- code : int or str An EPSG code. Strings will be converted to integers. Notes ----- The input code is not validated against an EPSG database. Returns ------- CRS """ obj = cls() obj._crs = _CRS.from_epsg(code) return obj
def test_equality(): """CRS are or are not equal""" _CRS.from_epsg(4326) == _CRS.from_proj4('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
def test_from_epsg_error(code): """Raise exception with invalid EPSG code""" with pytest.raises(ValueError): assert _CRS.from_epsg(code)
def test_from_epsg(): """Can create a CRS from EPSG code""" crs = _CRS.from_epsg(4326) assert crs.to_dict()['proj'] == 'longlat'
def test_linear_units(): """CRS linear units can be had""" assert _CRS.from_epsg(3857).linear_units == 'metre'
def test_equality(): """CRS are or are not equal""" _CRS.from_epsg(4326) == _CRS.from_proj4( '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
def test_from_epsg(): """Can create a CRS from EPSG code""" crs = _CRS.from_epsg(4326) assert crs.to_dict()['proj'] == 'longlat'
def test_from_epsg_error(code): """Raise exception with invalid EPSG code""" with pytest.raises(ValueError): assert _CRS.from_epsg(code)
def test_linear_units(): """CRS linear units can be had""" assert _CRS.from_epsg(3857).linear_units == 'metre'
def test_to_wkt__version__warning_gdal2(): with pytest.warns(UserWarning): _CRS.from_epsg(4326).to_wkt(version=WktVersion.WKT2_2019)
def test_to_wkt__version_invalid(): with pytest.raises(ValueError): _CRS.from_epsg(4326).to_wkt(version="INVALID")
def test_to_wkt__env_version(): with Env(OSR_WKT_FORMAT="WKT2_2018"): assert _CRS.from_epsg(4326).to_wkt().startswith('GEOGCRS["WGS 84",')
def test_to_wkt__version(version): assert _CRS.from_epsg(4326).to_wkt( version=version).startswith('GEOGCRS["WGS 84",')