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()
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
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()
def test_to_wkt(): """CRS converts to WKT""" assert _CRS.from_dict({'init': 'epsg:4326'}).to_wkt().startswith('GEOGCS["WGS 84",DATUM')
def test_is_projected(proj, expected): """CRS is or is not projected""" assert _CRS.from_dict(proj).is_projected is expected
def test_is_geographic(proj, expected): """CRS is or is not geographic""" assert _CRS.from_dict(proj).is_geographic is expected
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()
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()
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)
def test_to_wkt(): """CRS converts to WKT""" assert _CRS.from_dict({ 'init': 'epsg:4326' }).to_wkt().startswith('GEOGCS["WGS 84",DATUM')
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( )
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
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( )
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)