コード例 #1
0
ファイル: crs.py プロジェクト: DanLipsitt/rasterio
    def __init__(self, initialdata=None, **kwargs):
        """Make a CRS from a PROJ dict or mapping

        Parameters
        ----------
        initialdata : mapping, optional
            A dictionary or other mapping
        kwargs : mapping, optional
            Another mapping. Will be overlaid on the initialdata.

        Returns
        -------
        CRS

        """
        self._wkt = None
        self._data = None
        self._crs = None

        if initialdata or kwargs:

            data = dict(initialdata or {})
            data.update(**kwargs)
            data = {k: v for k, v in data.items() if k in all_proj_keys}
            self._crs = _CRS.from_dict(data)

        else:
            self._crs = _CRS()
コード例 #2
0
    def __init__(self, initialdata=None, **kwargs):
        """Make a CRS from a PROJ dict or mapping

        Parameters
        ----------
        initialdata : mapping, optional
            A dictionary or other mapping
        kwargs : mapping, optional
            Another mapping. Will be overlaid on the initialdata.

        Returns
        -------
        CRS

        """
        self._wkt = None
        self._data = None
        self._crs = None

        if initialdata or kwargs:
            data = dict(initialdata or {})
            data.update(**kwargs)
            data = {k: v for k, v in data.items() if k in all_proj_keys}
            self._crs = _CRS.from_dict(data)

        else:
            self._crs = _CRS()
コード例 #3
0
ファイル: crs.py プロジェクト: DanLipsitt/rasterio
    def from_dict(cls, initialdata=None, **kwargs):
        """Make a CRS from a PROJ dict

        Parameters
        ----------
        initialdata : mapping, optional
            A dictionary or other mapping
        kwargs : mapping, optional
            Another mapping. Will be overlaid on the initialdata.

        Returns
        -------
        CRS

        """
        obj = cls()
        obj._crs = _CRS.from_dict(initialdata, **kwargs)
        return obj
コード例 #4
0
    def from_dict(cls, initialdata=None, **kwargs):
        """Make a CRS from a PROJ dict

        Parameters
        ----------
        initialdata : mapping, optional
            A dictionary or other mapping
        kwargs : mapping, optional
            Another mapping. Will be overlaid on the initialdata.

        Returns
        -------
        CRS

        """
        obj = cls()
        obj._crs = _CRS.from_dict(initialdata, **kwargs)
        return obj
コード例 #5
0
ファイル: crs.py プロジェクト: vishalbelsare/rasterio
    def __init__(self, initialdata=None, **kwargs):
        """Make a CRS from a PROJ dict or mapping

        Parameters
        ----------
        initialdata : mapping, optional
            A dictionary or other mapping
        kwargs : mapping, optional
            Another mapping. Will be overlaid on the initialdata.

        Returns
        -------
        CRS

        """
        self._wkt = None
        self._data = None
        self._crs = None

        if initialdata or kwargs:
            self._crs = _CRS.from_dict(initialdata=initialdata, **kwargs)

        else:
            self._crs = _CRS()
コード例 #6
0
ファイル: test__crs.py プロジェクト: DanLipsitt/rasterio
def test_to_wkt():
    """CRS converts to WKT"""
    assert _CRS.from_dict({'init': 'epsg:4326'}).to_wkt().startswith('GEOGCS["WGS 84",DATUM')
コード例 #7
0
ファイル: test__crs.py プロジェクト: DanLipsitt/rasterio
def test_is_projected(proj, expected):
    """CRS is or is not projected"""
    assert _CRS.from_dict(proj).is_projected is expected
コード例 #8
0
ファイル: test__crs.py プロジェクト: DanLipsitt/rasterio
def test_is_geographic(proj, expected):
    """CRS is or is not geographic"""
    assert _CRS.from_dict(proj).is_geographic is expected
コード例 #9
0
ファイル: test__crs.py プロジェクト: DanLipsitt/rasterio
def test_from_dict_keywords():
    """Can create a CRS from keyword args, ignoring unknowns"""
    crs = _CRS.from_dict(init='epsg:3857', foo='bar')
    assert crs.to_dict()['proj'] == 'merc'
    assert 'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84"' in crs.to_wkt()
コード例 #10
0
ファイル: test__crs.py プロジェクト: DanLipsitt/rasterio
def test_from_dict():
    """Can create a _CRS from a dict"""
    crs = _CRS.from_dict({'init': 'epsg:3857'})
    assert crs.to_dict()['proj'] == 'merc'
    assert 'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84"' in crs.to_wkt()
コード例 #11
0
ファイル: test__crs.py プロジェクト: DanLipsitt/rasterio
def test_to_esri_wkt_fix_datum():
    """Morph to Esri form"""
    assert 'DATUM["D_North_American_1983"' in _CRS.from_dict(init='epsg:26913').to_wkt(morph_to_esri_dialect=True)
コード例 #12
0
def test_to_wkt():
    """CRS converts to WKT"""
    assert _CRS.from_dict({
        'init': 'epsg:4326'
    }).to_wkt().startswith('GEOGCS["WGS 84",DATUM')
コード例 #13
0
def test_is_projected(proj, expected):
    """CRS is or is not projected"""
    assert _CRS.from_dict(proj).is_projected is expected
コード例 #14
0
def test_is_geographic(proj, expected):
    """CRS is or is not geographic"""
    assert _CRS.from_dict(proj).is_geographic is expected
コード例 #15
0
def test_from_dict_keywords():
    """Can create a CRS from keyword args, ignoring unknowns"""
    crs = _CRS.from_dict(init='epsg:3857', foo='bar')
    assert crs.to_dict()['proj'] == 'merc'
    assert 'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84"' in crs.to_wkt(
    )
コード例 #16
0
def test_from_dict_bool_kwarg(south, epsg):
    """Confirm resolution of issue #2246"""
    crs = _CRS.from_dict({'proj': 'utm', 'zone': 31, 'south': south})
    assert crs.to_epsg() == epsg
コード例 #17
0
def test_from_dict():
    """Can create a _CRS from a dict"""
    crs = _CRS.from_dict({'init': 'epsg:3857'})
    assert crs.to_dict()['proj'] == 'merc'
    assert 'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84"' in crs.to_wkt(
    )
コード例 #18
0
def test_to_esri_wkt_fix_datum():
    """Morph to Esri form"""
    assert 'DATUM["D_North_American_1983"' in _CRS.from_dict(
        init='epsg:26913').to_wkt(morph_to_esri_dialect=True)