Esempio n. 1
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()
Esempio n. 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()
Esempio n. 3
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
Esempio n. 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
Esempio n. 5
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:
            self._crs = _CRS.from_dict(initialdata=initialdata, **kwargs)

        else:
            self._crs = _CRS()
Esempio n. 6
0
def test_to_wkt():
    """CRS converts to WKT"""
    assert _CRS.from_dict({'init': 'epsg:4326'}).to_wkt().startswith('GEOGCS["WGS 84",DATUM')
Esempio n. 7
0
def test_is_projected(proj, expected):
    """CRS is or is not projected"""
    assert _CRS.from_dict(proj).is_projected is expected
Esempio n. 8
0
def test_is_geographic(proj, expected):
    """CRS is or is not geographic"""
    assert _CRS.from_dict(proj).is_geographic is expected
Esempio n. 9
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()
Esempio n. 10
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()
Esempio n. 11
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)
Esempio n. 12
0
def test_to_wkt():
    """CRS converts to WKT"""
    assert _CRS.from_dict({
        'init': 'epsg:4326'
    }).to_wkt().startswith('GEOGCS["WGS 84",DATUM')
Esempio n. 13
0
def test_is_projected(proj, expected):
    """CRS is or is not projected"""
    assert _CRS.from_dict(proj).is_projected is expected
Esempio n. 14
0
def test_is_geographic(proj, expected):
    """CRS is or is not geographic"""
    assert _CRS.from_dict(proj).is_geographic is expected
Esempio n. 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(
    )
Esempio n. 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
Esempio n. 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(
    )
Esempio n. 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)