cartodb-4.42/lib/importer/misc/srid_from_gdal.py

12 lines
231 B
Python
Raw Normal View History

2024-04-06 13:25:13 +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))