当前位置: 首页>>代码示例>>Python>>正文


Python pyproj.CRS属性代码示例

本文整理汇总了Python中pyproj.CRS属性的典型用法代码示例。如果您正苦于以下问题:Python pyproj.CRS属性的具体用法?Python pyproj.CRS怎么用?Python pyproj.CRS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在pyproj的用法示例。


在下文中一共展示了pyproj.CRS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _parse_crs

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def _parse_crs(value):
        """ Method for parsing different inputs representing the same CRS enum. Examples:

        - 4326
        - 'EPSG:3857'
        - {'init': 32633}
        - pyproj.CRS(32743)
        """
        if isinstance(value, dict) and 'init' in value:
            value = value['init']
        if isinstance(value, pyproj.CRS):
            if value == CRSMeta._UNSUPPORTED_CRS:
                raise ValueError('sentinelhub-py supports only WGS 84 coordinate reference system with '
                                 'coordinate order lng-lat. However pyproj.CRS(4326) has coordinate order lat-lng')

            value = value.to_epsg()

        if isinstance(value, int):
            return str(value)
        if isinstance(value, str):
            return value.lower().strip('epsg: ')
        return value 
开发者ID:sentinel-hub,项目名称:sentinelhub-py,代码行数:24,代码来源:constants.py

示例2: test_utm

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def test_utm(self):
        known_values = (
            (13, 46, '32633'),
            (13, 0, '32633'),
            (13, -45, '32733'),
            (13, 0, '32633'),
            (13, -0.0001, '32733'),
            (13, -46, '32733')
        )
        for known_val in known_values:
            lng, lat, epsg = known_val
            with self.subTest(msg=epsg):
                crs = CRS.get_utm_from_wgs84(lng, lat)
                self.assertEqual(epsg, crs.value,
                                 msg="Expected {}, got {} for lng={},lat={}".format(epsg, crs.value, str(lng),
                                                                                    str(lat))) 
开发者ID:sentinel-hub,项目名称:sentinelhub-py,代码行数:18,代码来源:test_constants.py

示例3: test_crs_parsing

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def test_crs_parsing(self):
        test_cases = [
            (4326, CRS.WGS84),
            ('4326', CRS.WGS84),
            ('EPSG:3857', CRS.POP_WEB),
            ({'init': 'EPSG:32638'}, CRS.UTM_38N),
            (pyproj.CRS('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'), CRS.WGS84),
            (pyproj.CRS(3857), CRS.POP_WEB),
        ]
        for parse_value, expected_result in test_cases:
            with self.subTest(msg=str(parse_value)):
                parsed_result = CRS(parse_value)
                self.assertEqual(parsed_result, expected_result)

        with self.assertRaises(ValueError):
            CRS(pyproj.CRS(4326)) 
开发者ID:sentinel-hub,项目名称:sentinelhub-py,代码行数:18,代码来源:test_constants.py

示例4: test_proj4_radius_parameters_provided

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def test_proj4_radius_parameters_provided(self):
        """Test proj4_radius_parameters with a/b."""
        from pyresample import utils
        a, b = utils.proj4.proj4_radius_parameters(
            '+proj=stere +a=6378273 +b=6356889.44891',
        )
        np.testing.assert_almost_equal(a, 6378273)
        np.testing.assert_almost_equal(b, 6356889.44891)

        # test again but force pyproj <2 behavior
        with mock.patch.object(utils.proj4, 'CRS', None):
            a, b = utils.proj4.proj4_radius_parameters(
                '+proj=stere +a=6378273 +b=6356889.44891',
            )
            np.testing.assert_almost_equal(a, 6378273)
            np.testing.assert_almost_equal(b, 6356889.44891) 
开发者ID:pytroll,项目名称:pyresample,代码行数:18,代码来源:test_utils.py

示例5: test_proj4_radius_parameters_ellps

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def test_proj4_radius_parameters_ellps(self):
        """Test proj4_radius_parameters with ellps."""
        from pyresample import utils
        a, b = utils.proj4.proj4_radius_parameters(
            '+proj=stere +ellps=WGS84',
        )
        np.testing.assert_almost_equal(a, 6378137.)
        np.testing.assert_almost_equal(b, 6356752.314245, decimal=6)

        # test again but force pyproj <2 behavior
        with mock.patch.object(utils.proj4, 'CRS', None):
            a, b = utils.proj4.proj4_radius_parameters(
                '+proj=stere +ellps=WGS84',
            )
            np.testing.assert_almost_equal(a, 6378137.)
            np.testing.assert_almost_equal(b, 6356752.314245, decimal=6) 
开发者ID:pytroll,项目名称:pyresample,代码行数:18,代码来源:test_utils.py

示例6: test_proj4_radius_parameters_default

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def test_proj4_radius_parameters_default(self):
        """Test proj4_radius_parameters with default parameters."""
        from pyresample import utils
        a, b = utils.proj4.proj4_radius_parameters(
            '+proj=lcc +lat_0=10 +lat_1=10',
        )
        # WGS84
        np.testing.assert_almost_equal(a, 6378137.)
        np.testing.assert_almost_equal(b, 6356752.314245, decimal=6)

        # test again but force pyproj <2 behavior
        with mock.patch.object(utils.proj4, 'CRS', None):
            a, b = utils.proj4.proj4_radius_parameters(
                '+proj=lcc +lat_0=10 +lat_1=10',
            )
            # WGS84
            np.testing.assert_almost_equal(a, 6378137.)
            np.testing.assert_almost_equal(b, 6356752.314245, decimal=6) 
开发者ID:pytroll,项目名称:pyresample,代码行数:20,代码来源:test_utils.py

示例7: test_proj4_radius_parameters_spherical

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def test_proj4_radius_parameters_spherical(self):
        """Test proj4_radius_parameters in case of a spherical earth."""
        from pyresample import utils
        a, b = utils.proj4.proj4_radius_parameters(
            '+proj=stere +R=6378273',
        )
        np.testing.assert_almost_equal(a, 6378273.)
        np.testing.assert_almost_equal(b, 6378273.)

        # test again but force pyproj <2 behavior
        with mock.patch.object(utils.proj4, 'CRS', None):
            a, b = utils.proj4.proj4_radius_parameters(
                '+proj=stere +R=6378273',
            )
            np.testing.assert_almost_equal(a, 6378273.)
            np.testing.assert_almost_equal(b, 6378273.) 
开发者ID:pytroll,项目名称:pyresample,代码行数:18,代码来源:test_utils.py

示例8: rasterio_crs

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def rasterio_crs(projparams):
    """
    Return a rasterio.crs.CRS object that corresponds to the given parameters.
    See: https://pyproj4.github.io/pyproj/stable/crs_compatibility.html#converting-from-pyproj-crs-crs-to-rasterio-crs-crs

    Args:
        projparams (int, str, dict, pyproj.CRS): PROJ parameters

    Returns:
        rasterio.crs.CRS: object that can be used with rasterio
    """
    proj_crs = pyproj_crs(projparams)
    if LooseVersion(rasterio.__gdal_version__) < LooseVersion("3.0.0"):
        rio_crs = RioCRS.from_wkt(proj_crs.to_wkt(WktVersion.WKT1_GDAL))
    else:
        rio_crs = RioCRS.from_wkt(proj_crs.to_wkt())
    return rio_crs 
开发者ID:cmla,项目名称:s2p,代码行数:19,代码来源:geographiclib.py

示例9: pyproj_crs

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def pyproj_crs(projparams):
    """
    Wrapper around pyproj to return a pyproj.crs.CRS object that corresponds
    to the given parameters

    Args:
        projparams (int, str, dict): CRS parameters

    Returns:
        pyproj.crs.CRS: object that defines a CRS
    """
    if isinstance(projparams, str):
        try:
            projparams = int(projparams)
        except (ValueError, TypeError):
            pass
    return pyproj.crs.CRS(projparams) 
开发者ID:cmla,项目名称:s2p,代码行数:19,代码来源:geographiclib.py

示例10: pyproj_transform

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def pyproj_transform(x, y, in_crs, out_crs, z=None):
    """
    Wrapper around pyproj to convert coordinates from an EPSG system to another.

    Args:
        x (scalar or array): x coordinate(s), expressed in in_crs
        y (scalar or array): y coordinate(s), expressed in in_crs
        in_crs (pyproj.crs.CRS or int): input coordinate reference system or EPSG code
        out_crs (pyproj.crs.CRS or int): output coordinate reference system or EPSG code
        z (scalar or array): z coordinate(s), expressed in in_crs

    Returns:
        scalar or array: x coordinate(s), expressed in out_crs
        scalar or array: y coordinate(s), expressed in out_crs
        scalar or array (optional if z): z coordinate(s), expressed in out_crs
    """
    transformer = pyproj.Transformer.from_crs(in_crs, out_crs, always_xy=True)
    if z is None:
        return transformer.transform(x, y)
    else:
        return transformer.transform(x, y, z) 
开发者ID:cmla,项目名称:s2p,代码行数:23,代码来源:geographiclib.py

示例11: __new__

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def __new__(mcs, cls, bases, classdict):
        """ This is executed at the beginning of runtime when CRS class is created
        """
        for direction, direction_value in [('N', '6'), ('S', '7')]:
            for zone in range(1, 61):
                classdict['UTM_{}{}'.format(zone, direction)] = '32{}{}'.format(direction_value, str(zone).zfill(2))

        return super().__new__(mcs, cls, bases, classdict) 
开发者ID:sentinel-hub,项目名称:sentinelhub-py,代码行数:10,代码来源:constants.py

示例12: __call__

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def __call__(cls, crs_value, *args, **kwargs):
        """ This is executed whenever CRS('something') is called
        """
        # pylint: disable=signature-differs
        crs_value = cls._parse_crs(crs_value)

        if isinstance(crs_value, str) and not cls.has_value(crs_value) and crs_value.isdigit() and len(crs_value) >= 4:
            crs_name = 'EPSG_{}'.format(crs_value)
            extend_enum(cls, crs_name, crs_value)

        return super().__call__(crs_value, *args, **kwargs) 
开发者ID:sentinel-hub,项目名称:sentinelhub-py,代码行数:13,代码来源:constants.py

示例13: __str__

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def __str__(self):
        """ Method for casting CRS enum into string
        """
        return self.ogc_string() 
开发者ID:sentinel-hub,项目名称:sentinelhub-py,代码行数:6,代码来源:constants.py

示例14: __repr__

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def __repr__(self):
        """ Method for retrieving CRS enum representation
        """
        return "CRS('{}')".format(self.value) 
开发者ID:sentinel-hub,项目名称:sentinelhub-py,代码行数:6,代码来源:constants.py

示例15: epsg

# 需要导入模块: import pyproj [as 别名]
# 或者: from pyproj import CRS [as 别名]
def epsg(self):
        """ EPSG code property

        :return: EPSG code of given CRS
        :rtype: int
        """
        return int(self.value) 
开发者ID:sentinel-hub,项目名称:sentinelhub-py,代码行数:9,代码来源:constants.py


注:本文中的pyproj.CRS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。