Select to view content in your preferred language

Adjusting properties on the SpatialReference class

919
6
04-06-2012 05:57 AM
BKuiper
Frequent Contributor
Hi

I'm trying to adjust the SpatialReference using the SpatialReference class, but it doesn't seem to be working. In my example i'm trying to adjust the centralMeridian, but the final output still has the original value of -96.0.

Anybody has an idea how to make this work ?

Here is my example:

#!/usr/bin/env python

import arcpy, sys

Output_Spatial_Reference = "PROJCS['North_America_Lambert_Conformal_Conic',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-96.0],PARAMETER['Standard_Parallel_1',20.0],PARAMETER['Standard_Parallel_2',60.0],PARAMETER['Latitude_Of_Origin',40.0],UNIT['Meter',1.0]];-35214300 -28218500 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision"

sr = arcpy.SpatialReference()
sr.loadFromString(Output_Spatial_Reference)
sr.centralMeridian = 10.0
result = sr.exportToString()

print "printing result:"
print result
Tags (2)
0 Kudos
6 Replies
markdenil
Frequent Contributor
have you tried
sr.centralMeridianInDegrees = 10.0
?
0 Kudos
BKuiper
Frequent Contributor
have you tried
sr.centralMeridianInDegrees = 10.0
?


Good idea, but that doesn't work as well.

I tried two different approaches, but it doesn't seem to work. Anybody has some ideas on what is going wrong?

here is my updated script

#!/usr/bin/env python

import arcpy, sys

# using existing string
Output_Spatial_Reference = "PROJCS['North_America_Lambert_Conformal_Conic',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-96.0],PARAMETER['Standard_Parallel_1',20.0],PARAMETER['Standard_Parallel_2',60.0],PARAMETER['Latitude_Of_Origin',40.0],UNIT['Meter',1.0]];-35214300 -28218500 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision"

sr = arcpy.SpatialReference()
sr.loadFromString(Output_Spatial_Reference)
sr.centralMeridian = -10.0
sr.centralMeridianInDegrees = -10.0
result = sr.exportToString()

print "printing result:"
print result

# using factory code

sr = arcpy.SpatialReference()
sr.factoryCode = 102009
sr.centralMeridian = -10.0
sr.centralMeridianInDegrees = -10.0
sr.create()

result = sr.exportToString()

print "printing result:"
print result


btw: i'm using Desktop 10.1 Prerelease, ArcObjects SDK .NET 10.1 Prerelease and ArcGIS Runtime BETA 2.
0 Kudos
BKuiper
Frequent Contributor
It seems that another user had the same problem in 2007, but no solution is given

http://forums.esri.com/Thread.asp?c=93&f=984&t=231893
0 Kudos
BKuiper
Frequent Contributor
Found another post. This might exactly explain it:
http://forums.arcgis.com/threads/32731-Modify-Spatial-Reference-Object

parameters are documented as read/write but are exactly only read. I guess the arcpy team should update the documentation or help me provide a working example.
0 Kudos
BKuiper
Frequent Contributor
So can anybody from the arcpy team confirm my findings?

It seems that these settings are only read-only, although they are marked read/write in the documentation.

It would be really helpful if these settings where actually read/write.

Thank you.
MarcHunter1
Occasional Contributor

How has such an old problem persisted to Arc Pro documentation? Can anyone from Esri answer this?

0 Kudos