How do you create a custom projection (10.1)  in Python?

Discussion created by kimo on May 20, 2012
I want to simply modify the Central Meridian for a standard projection South Polar Stereographic. The default is 0.0, which is upside down for me, I need 180.0

How hard can this be - according to the documentation:

newSR - arcpy.SpatialReference("South Polar Stereographic")
newSR.CentralMeridianAsDegrees = 180.0
# then use it...

But this does not work, nothing changes. It appears that the newSR object is read-only. I can retrieve all the properties but not change them, even though they are read/write according to the help.

So I resorted to exporting to a text string and hack the changes in there.... but that did not work either.
After wasting the good part of half a day I have discovered that the string is written out with single quotes, but the reader must have it in double quotes.
What is it supposed to be, single or double or either?

    newStringSR = newSR.exportToString() # have to hack because read-only
    newStringSR = newStringSR.replace("South_Pole_Stereographic","South_Pole_Stereographic_"+suffix)
    newStringSR = newStringSR.replace("'Central_Meridian',0.0","'Central_Meridian',"+str(float(domainCentralMeridian)))
    newStringSR = newStringSR.replace("'","\"") # bugfix kludge for v 10.1
    # print newStringSR and read back in
    f1 = open(domainWS+"/South_Pole_Stereographic_"+suffix+".prj","w")
    # new domain boundary

Surely there must be a better way of creating a custom projection! I have tried using a factoryCode.
Do I have to create a blank SR and populate everything by hand from a template? How do I make it writeable?
I have found that extracting any object from Describe() is trouble because they are set to be read-only.
Is there a way of making a writable copy?
Doing it by handin ArcMap works but is not an option on this forum of course.