diff --git a/geokit/core/srs.py b/geokit/core/srs.py index 3e5055e..fa44b9d 100644 --- a/geokit/core/srs.py +++ b/geokit/core/srs.py @@ -28,6 +28,7 @@ def loadSRS(source): Example of acceptable objects are... * osr.SpatialReference object * An EPSG integer ID + * A standardized srs str definition such as 'EPSG:4326' or 'ESRI:53003' * a string corresponding to one of the systems found in geokit.srs.SRSCOMMON * a WKT string @@ -51,7 +52,13 @@ def loadSRS(source): # assume a name for one of the common SRS's was given srs = SRSCOMMON[source] else: - srs.ImportFromWkt(source) # assume a Wkt string was input + try: + # try handling as a standardized epsg or esri etc. code + srs = osr.SpatialReference() + _val = srs.SetFromUserInput(source) + assert _val==0 + except: + srs.ImportFromWkt(source) # assume a Wkt string was input elif(isinstance(source, int)): srs.ImportFromEPSG(source) else: diff --git a/geokit/test/test_02_srs.py b/geokit/test/test_02_srs.py index fa11ea7..4955f66 100644 --- a/geokit/test/test_02_srs.py +++ b/geokit/test/test_02_srs.py @@ -56,8 +56,11 @@ def test_loadSRS(): s1 = srs.loadSRS(srs.EPSG4326) # Test an EPSG identifier s2 = srs.loadSRS(4326) + # Test an EPSG code + s3 = srs.loadSRS("epsg:4326") # Are they the same? assert s1.IsSame(s2) + assert s1.IsSame(s3) # test an invalid srs, must raise error with pytest.raises(AssertionError):