cartodb/lib/importer/misc/srid_from_gdal.py

12 lines
230 B
Python
Raw Normal View History

2020-06-15 10:58:47 +08:00
import sys
from osgeo import gdal, osr
f = sys.argv[1]
g = gdal.Open(f)
proj = g.GetProjection()
srs = osr.SpatialReference()
srs.ImportFromESRI([proj])
srs.AutoIdentifyEPSG()
srid = srs.GetAuthorityCode(None)
print "%s" %(srid)