<?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 Re: arcpy SDE layer file data source issue in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/arcpy-sde-layer-file-data-source-issue/m-p/349069#M3785</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think I know the problem.&amp;nbsp; The simple solution is to first try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;desc = arcpy.Describe(lyr)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and not&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(lyr.dataSource)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The longer explanation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had someone in my office sent me a layer file created using 9.3 Desktop to a 9.3 SDE (as well as a 10.0 layer file pointing to a 10.0 SDE).&amp;nbsp; When I added their layer file to my 10.0 map document it displayed just fine, that is because we are on the same network and I can connect to the same SDE server as they can (I'm thinking this is similar to your workplace environment).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But when I run the following I get the same error message that you are seeing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; mxd = arcpy.mapping.MapDocument("current")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; lyr = arcpy.mapping.ListLayers(mxd)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print lyr.dataSource&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Users\UserName\AppData\Roaming\ESRI\ArcCatalog\demo.sde\sde.DBO.layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; desc = arcpy.Describe(lyr.dataSource)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Runtime error &amp;lt;type 'exceptions.IOError'&amp;gt;: "C:\Users\UserName\AppData\Roaming\ESRI\ArcCatalog\demo.sde\sde.DBO.layer" does not exist&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is because the layer file is persisting the original connection information as a property.&amp;nbsp; When I print lyr.dataSource I get the path to the connection file above.&amp;nbsp; The .sde file does NOT exist on my local machine so we should expect it to fail because that is what it is looking for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When we remove the lyr.dataSource and use&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;desc = arcpy.Describe(lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print desc.spatialReference.name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GCS_WGS_1984&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works because it is using the current connection info rather than the property stored on the layer file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I create a new local connection and if I perform a lyr.replaceDataSource using my local SDE connection file info, both methods work without error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 08 Oct 2011 18:36:06 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2011-10-08T18:36:06Z</dc:date>
    <item>
      <title>arcpy SDE layer file data source issue</title>
      <link>https://community.esri.com/t5/mapping-questions/arcpy-sde-layer-file-data-source-issue/m-p/349068#M3784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To simply state my problem...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have two layers in my TOC. They both have the same SDE data source. However, one was added as a layer file. The issue is that I am trying to get the spatial reference for any layer in the TOC and when I get to the layer added as a layer file, I get a runtime error when I try to describe the spatial reference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for lyr in lyrList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.name
&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.dataSource
&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(lyr.dataSource)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print desc.spatialReference.name
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In line 3 above, my dataSource for the layer file points to the "C:\Documents and Settings\...\bnd", while the non-layer file points to "Database Connections\me@1.sde\bnd"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My error is in line 4 on the layer file: "Runtime error &amp;lt;type 'exceptions.IOError'&amp;gt;: C:\Documents and Settings\bhaney\Application Data\ESRI\ArcCatalog\orwa_sde@orsovctr.sde\OSODBA.Plan_Area_Boundary\OSODBA.PLANBDY_POLY does not exist"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this a configuration issue? Is this a known issue?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ryan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:25:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/arcpy-sde-layer-file-data-source-issue/m-p/349068#M3784</guid>
      <dc:creator>RyanKelley</dc:creator>
      <dc:date>2021-12-11T16:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy SDE layer file data source issue</title>
      <link>https://community.esri.com/t5/mapping-questions/arcpy-sde-layer-file-data-source-issue/m-p/349069#M3785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think I know the problem.&amp;nbsp; The simple solution is to first try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;desc = arcpy.Describe(lyr)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and not&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(lyr.dataSource)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The longer explanation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had someone in my office sent me a layer file created using 9.3 Desktop to a 9.3 SDE (as well as a 10.0 layer file pointing to a 10.0 SDE).&amp;nbsp; When I added their layer file to my 10.0 map document it displayed just fine, that is because we are on the same network and I can connect to the same SDE server as they can (I'm thinking this is similar to your workplace environment).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But when I run the following I get the same error message that you are seeing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; mxd = arcpy.mapping.MapDocument("current")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; lyr = arcpy.mapping.ListLayers(mxd)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print lyr.dataSource&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Users\UserName\AppData\Roaming\ESRI\ArcCatalog\demo.sde\sde.DBO.layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; desc = arcpy.Describe(lyr.dataSource)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Runtime error &amp;lt;type 'exceptions.IOError'&amp;gt;: "C:\Users\UserName\AppData\Roaming\ESRI\ArcCatalog\demo.sde\sde.DBO.layer" does not exist&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is because the layer file is persisting the original connection information as a property.&amp;nbsp; When I print lyr.dataSource I get the path to the connection file above.&amp;nbsp; The .sde file does NOT exist on my local machine so we should expect it to fail because that is what it is looking for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When we remove the lyr.dataSource and use&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;desc = arcpy.Describe(lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print desc.spatialReference.name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GCS_WGS_1984&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works because it is using the current connection info rather than the property stored on the layer file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I create a new local connection and if I perform a lyr.replaceDataSource using my local SDE connection file info, both methods work without error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Oct 2011 18:36:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/arcpy-sde-layer-file-data-source-issue/m-p/349069#M3785</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2011-10-08T18:36:06Z</dc:date>
    </item>
  </channel>
</rss>

