I have a tif image containing its CRS. I would like to extract the parameter "central_meridian". I have the following piece of code:
from osgeo import gdal,osr ds=gdal.Open(r'hrs0000bf5c_07_if177l_trr3_CAT_scale_trial_p.img.tif') prj=ds.GetProjection() print prj srs=osr.SpatialReference(wkt=prj) print srs.GetAttrValue('PARAMETER',0) print srs.GetAttrValue('PARAMETER',1) The output I get is the following:
PROJCS["Mars_Npolar_Stereo",GEOGCS["GCS_Unknown",DATUM["Unknown",SPHEROID["S_Unknown",3396190,169.8944472236118]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",90],PARAMETER["central_meridian",160.0712280273438],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]]] latitude_of_origin 90 I would like to fetch the second parameter "central_meridian" but i don't know how to do it? Any ideas?
##EDITIf trying to open a list of files given by a list like:
from osgeo import gdal,osr from gdalconst import GA_ReadOnly
f = open('list.txt') for line in iter(f): print line ds=gdal.Open(line,GA_ReadOnly) prj=ds.GetProjection() srs=osr.SpatialReference(wkt=prj) print line + " " + srs.GetProjParm( osr.SRS_PP_CENTRAL_MERIDIAN) f.close() I get the following error: ERROR 4: `frt0000703c_07_if187l_trr3_CAT_scale_trial_p.img.tif ' does not exist in the file system, and is not recognised as a supported dataset name.
I tried different ways to do it and went through documentation but no luck. Any ideas why it does not recognizes it as a filename?