<?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 change the data source of mxd or layer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-the-data-source-of-mxd-or-layer/m-p/86938#M6804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to change the data source of layers in an mxd-file with a python script and found several possible solutions: e.g.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. mxd.replaceWorkspaces(...)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. lyr.replaceDataSource(...)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Both data sources (the new and old one) are an ArcSDE (Oracle), but the Owners are different.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;No matter which Function (1 or 2) i use, the data source change works fine but an other problem occurs:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The symbology of one Layer was set to default:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Symbologytype of the Layer: UNIQUE_VALUES&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And the Value Field is an other than before the data source was changed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have no idea why. The new FeatureClass has the same name as the old one (except the owner-part in front of the Featureclass name) and the Value Field also exists in the new FeatureClass.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any idea what could be the reason for this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I open the mxd-file in ArcMap and set a new datasource (Properties\Source\Set Data Source...) the same problem occurs --&amp;gt; the symbology is gone &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(I have exported the Layer and attached it as a zip, so you can try to change the data source, yourself)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mickey&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Apr 2014 13:12:58 GMT</pubDate>
    <dc:creator>MickeyO_Neil</dc:creator>
    <dc:date>2014-04-08T13:12:58Z</dc:date>
    <item>
      <title>change the data source of mxd or layer</title>
      <link>https://community.esri.com/t5/python-questions/change-the-data-source-of-mxd-or-layer/m-p/86938#M6804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to change the data source of layers in an mxd-file with a python script and found several possible solutions: e.g.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. mxd.replaceWorkspaces(...)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. lyr.replaceDataSource(...)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Both data sources (the new and old one) are an ArcSDE (Oracle), but the Owners are different.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;No matter which Function (1 or 2) i use, the data source change works fine but an other problem occurs:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The symbology of one Layer was set to default:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Symbologytype of the Layer: UNIQUE_VALUES&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And the Value Field is an other than before the data source was changed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have no idea why. The new FeatureClass has the same name as the old one (except the owner-part in front of the Featureclass name) and the Value Field also exists in the new FeatureClass.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any idea what could be the reason for this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I open the mxd-file in ArcMap and set a new datasource (Properties\Source\Set Data Source...) the same problem occurs --&amp;gt; the symbology is gone &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(I have exported the Layer and attached it as a zip, so you can try to change the data source, yourself)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mickey&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 13:12:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-the-data-source-of-mxd-or-layer/m-p/86938#M6804</guid>
      <dc:creator>MickeyO_Neil</dc:creator>
      <dc:date>2014-04-08T13:12:58Z</dc:date>
    </item>
  </channel>
</rss>

