<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Modify Spatial Reference Object in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/modify-spatial-reference-object/m-p/318117#M24694</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to modify a spatial reference object to change the central meridian of a Mollweide projection. The documentation for the Spatial Reference Object lists the centralMeridian property as read-write but when I try and modify it the value doesn't change. Am I missing something obvious? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code below. Running ArcGIS 10, SP2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code below runs with no errors:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outputPrj = r'C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Projected Coordinate Systems\World\Mollweide (world).prj'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;spatialRef = arcpy.SpatialReference(outputPrj)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print 'central meridian', spatialRef.centralMeridian&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;spatialRef.centralMeridian = -70.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print 'modified ref central meridian', spatialRef.centralMeridian&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and it prints the text below, showing that the property hasn't changed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;central meridian 0.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;modified ref central meridian 0.0&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2011 18:42:33 GMT</pubDate>
    <dc:creator>GregYetman</dc:creator>
    <dc:date>2011-06-15T18:42:33Z</dc:date>
    <item>
      <title>Modify Spatial Reference Object</title>
      <link>https://community.esri.com/t5/python-questions/modify-spatial-reference-object/m-p/318117#M24694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to modify a spatial reference object to change the central meridian of a Mollweide projection. The documentation for the Spatial Reference Object lists the centralMeridian property as read-write but when I try and modify it the value doesn't change. Am I missing something obvious? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code below. Running ArcGIS 10, SP2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code below runs with no errors:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outputPrj = r'C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Projected Coordinate Systems\World\Mollweide (world).prj'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;spatialRef = arcpy.SpatialReference(outputPrj)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print 'central meridian', spatialRef.centralMeridian&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;spatialRef.centralMeridian = -70.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print 'modified ref central meridian', spatialRef.centralMeridian&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and it prints the text below, showing that the property hasn't changed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;central meridian 0.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;modified ref central meridian 0.0&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2011 18:42:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modify-spatial-reference-object/m-p/318117#M24694</guid>
      <dc:creator>GregYetman</dc:creator>
      <dc:date>2011-06-15T18:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Spatial Reference Object</title>
      <link>https://community.esri.com/t5/python-questions/modify-spatial-reference-object/m-p/318118#M24695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The spatial reference object is read-only. See the old Geoprocessor Programming Model 9.3 PDF.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One way to change the central meridian is to manually edit and save a modified spatial reference file after editing in ArcCatalog.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise you have to dump the parameters to a string, do a search and replace and then create an object from the complex string object. I can't believe that this is as intended.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
outputPrj = r'C:\temp\Mollweide (world).prj'
spatialRef = arcpy.SpatialReference()
spatialRef.createFromFile(outputPrj)
stRef = spatialRef.exportToString()
stRef = stRef.replace("Central_Meridian',0.0","Central_Meridian',-70.1")
spRef2 = arcpy.SpatialReference()
spRef2.loadFromString(stRef)
print spRef2.name,spRef2.centralMeridian
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see that the ArcGIS 10 help suggests some spatial reference properties are read/write. But ArcGIS 9.3 marks them all as read-only. I thought that it may be that sourcing from a protected directory may make them read-only, but that was not the case. I also tried creating from a factory code, setting properties and using sr.create() (which is necessary) but the properties are still read-only.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:07:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modify-spatial-reference-object/m-p/318118#M24695</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-11T15:07:19Z</dc:date>
    </item>
  </channel>
</rss>

