[gdal-dev] Get specific parameter in CRS information with Python gdal

Ramiro Marco Figuera r.marcofiguera at jacobs-university.de
Tue Oct 18 02:38:08 PDT 2016


Hi,

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

The code is fetching the first parameter: latitude_of_origin 90 but i 
would like to get the second one "central_meridian" but i don't know how 
to do it? Any ideas?

Thanks a lot.


-- 
Ramiro Marco Figuera
Research Associate - PhD Student
Department of Physics and Earth Sciences
Jacobs University Bremen
Campus Ring 1, 28759 Bremen, Germany
Office: Research III, Room 99b
Tel: +49 (0)421 200 3226



More information about the gdal-dev mailing list