I am using Landsat imagery from the USGS. Those who use them may know that the projection attribute is wrong (everything is in the Northern hemisphere). I have a script to process tar.gz files and output a stacklayer with selected bands of interest. I deal with the projection error by modifying the EPSG value and writing a new projection like this:
orgeoproj = dst.GetProjection() # North projection
osn = osr.SpatialReference()
osn.ImportFromWkt(dst.GetProjection())
nEPSG= int(osn.GetAttrValue("AUTHORITY",1))
sEPSG= nEPSG + 100
print "mudando EPSG Norte a Sur"
osn.SetFromUserInput("EPSG:%d"%sEPSG)
modgeoproj = osn.ExportToWkt()
When I print orgeoproj
(original geoproject), the output has Authority values like:
PROJCS["WGS 84 / UTM zone 23N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-45],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32623"]]
After modifying the EPSG value, the modgeoproj
is OK now and showing the right EPSG value for the southern hemisphere! The problem rises when I write the modgeoproj
with SetProjection
(modgeoproj) to the stacklayer and then load it with another script.
After a GetProjection()
, I only get:
PROJCS["WGS_1984_UTM_Zone_23S",GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-45],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]]
There's no Authority Information and I need it! What can possibly be wrong?