<?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: How do I remove layers with broken data sources? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544292#M42456</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We have 15 years of legacy mxds and most have data sources long gone.&lt;/P&gt;&lt;P&gt;This way, I can log the broken data sources, remove them and then allow the end users to replace the data as needed.&lt;/P&gt;&lt;P&gt;Otherwise, it takes a VERY LONG TIME to open the mxds w/ all the broken data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Sep 2014 18:47:58 GMT</pubDate>
    <dc:creator>TedPrescott</dc:creator>
    <dc:date>2014-09-05T18:47:58Z</dc:date>
    <item>
      <title>How do I remove layers with broken data sources?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544288#M42452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to scroll through an mxd and remove any layers that have broken data sources.&lt;/P&gt;&lt;P&gt;I have found&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; brknList = arcpy.mapping.ListBrokenDataSources(inMXD)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for lyr in arcpy.mapping.ListLayers(mxd, "*",df):&lt;/P&gt;&lt;P&gt;arcpy.mapping.RemoveLayer(df, lyr)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;both work well, but not together.&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2014 15:54:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544288#M42452</guid>
      <dc:creator>TedPrescott</dc:creator>
      <dc:date>2014-09-05T15:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove layers with broken data sources?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544289#M42453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;arcpy Layer objects have a isBroken property you can check if is true or not.&amp;nbsp; If it is true, then have your script remove the layer, instead of all layers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14099331267969064" jivemacro_uid="_14099331267969064" modifiedtitle="true"&gt;
&lt;P&gt;for layer in arcpy.mapping.ListLayers(mxd, "*", df):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if layer.isBroken:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.RemoveLayer(df, layer)&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2014 16:07:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544289#M42453</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-09-05T16:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove layers with broken data sources?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544290#M42454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works GREAT !!!&lt;/P&gt;&lt;P&gt;Your few lines of code just saved me from several days of frustration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your prompt reply.&lt;/P&gt;&lt;P&gt;Ted&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2014 17:58:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544290#M42454</guid>
      <dc:creator>TedPrescott</dc:creator>
      <dc:date>2014-09-05T17:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove layers with broken data sources?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544291#M42455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are quite welcome.&amp;nbsp; Just out of curiousity, why are you needing to delete so many layers from so many map?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2014 18:43:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544291#M42455</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-09-05T18:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove layers with broken data sources?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544292#M42456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We have 15 years of legacy mxds and most have data sources long gone.&lt;/P&gt;&lt;P&gt;This way, I can log the broken data sources, remove them and then allow the end users to replace the data as needed.&lt;/P&gt;&lt;P&gt;Otherwise, it takes a VERY LONG TIME to open the mxds w/ all the broken data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2014 18:47:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544292#M42456</guid>
      <dc:creator>TedPrescott</dc:creator>
      <dc:date>2014-09-05T18:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove layers with broken data sources?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544293#M42457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yea that would be quite a pain to do manually.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't mind can you mark this question answered, will make it easier for people to find in the future if they have a similar issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2014 18:50:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-remove-layers-with-broken-data-sources/m-p/544293#M42457</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-09-05T18:50:00Z</dc:date>
    </item>
  </channel>
</rss>

