Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
def test_equality():
    """CRS are or are not equal"""
    _CRS.from_epsg(4326) == _CRS.from_proj4('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
Ejemplo n.º 4
0
def test_from_epsg_error(code):
    """Raise exception with invalid EPSG code"""
    with pytest.raises(ValueError):
        assert _CRS.from_epsg(code)
Ejemplo n.º 5
0
def test_from_epsg():
    """Can create a CRS from EPSG code"""
    crs = _CRS.from_epsg(4326)
    assert crs.to_dict()['proj'] == 'longlat'
Ejemplo n.º 6
0
def test_linear_units():
    """CRS linear units can be had"""
    assert _CRS.from_epsg(3857).linear_units == 'metre'
Ejemplo n.º 7
0
def test_equality():
    """CRS are or are not equal"""
    _CRS.from_epsg(4326) == _CRS.from_proj4(
        '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
Ejemplo n.º 8
0
def test_from_epsg():
    """Can create a CRS from EPSG code"""
    crs = _CRS.from_epsg(4326)
    assert crs.to_dict()['proj'] == 'longlat'
Ejemplo n.º 9
0
def test_from_epsg_error(code):
    """Raise exception with invalid EPSG code"""
    with pytest.raises(ValueError):
        assert _CRS.from_epsg(code)
Ejemplo n.º 10
0
def test_linear_units():
    """CRS linear units can be had"""
    assert _CRS.from_epsg(3857).linear_units == 'metre'
Ejemplo n.º 11
0
def test_to_wkt__version__warning_gdal2():
    with pytest.warns(UserWarning):
        _CRS.from_epsg(4326).to_wkt(version=WktVersion.WKT2_2019)
Ejemplo n.º 12
0
def test_to_wkt__version_invalid():
    with pytest.raises(ValueError):
        _CRS.from_epsg(4326).to_wkt(version="INVALID")
Ejemplo n.º 13
0
def test_to_wkt__env_version():
    with Env(OSR_WKT_FORMAT="WKT2_2018"):
        assert _CRS.from_epsg(4326).to_wkt().startswith('GEOGCRS["WGS 84",')
Ejemplo n.º 14
0
def test_to_wkt__version(version):
    assert _CRS.from_epsg(4326).to_wkt(
        version=version).startswith('GEOGCRS["WGS 84",')