<?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 Remove layers from a project without opening in ArcMap Questions</title>
    <link>https://community.esri.com/t5/arcmap-questions/remove-layers-from-a-project-without-opening/m-p/191857#M434</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Sometime, my project .mxd crash because a layer is not well supported. So I am wondering if it is possible to remove a layer from a project without opening it (ArcGIS Desktop).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Aug 2018 15:33:43 GMT</pubDate>
    <dc:creator>ALL</dc:creator>
    <dc:date>2018-08-01T15:33:43Z</dc:date>
    <item>
      <title>Remove layers from a project without opening</title>
      <link>https://community.esri.com/t5/arcmap-questions/remove-layers-from-a-project-without-opening/m-p/191857#M434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Sometime, my project .mxd crash because a layer is not well supported. So I am wondering if it is possible to remove a layer from a project without opening it (ArcGIS Desktop).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Aug 2018 15:33:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/remove-layers-from-a-project-without-opening/m-p/191857#M434</guid>
      <dc:creator>ALL</dc:creator>
      <dc:date>2018-08-01T15:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Remove layers from a project without opening</title>
      <link>https://community.esri.com/t5/arcmap-questions/remove-layers-from-a-project-without-opening/m-p/191858#M435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy/what-is-arcpy-.htm"&gt;ArcPy&lt;/A&gt; to do that, and run the script in ArcCatalog, ArcMap, or in an IDE like IDLE (which comes installed with ArcGIS).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some of the classes and functions you'd probably want to use :&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/mapdocument-class.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/mapdocument-class.htm"&gt;MapDocument—Help | ArcGIS Desktop&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/listdataframes.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/listdataframes.htm"&gt;ListDataFrames—Help | ArcGIS Desktop&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/listlayers.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/listlayers.htm"&gt;ListLayers—Help | ArcGIS Desktop&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/removelayer.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/removelayer.htm"&gt;RemoveLayer—Help | ArcGIS Desktop&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's an example:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;arcpy.env.workspace=r"C:\DirectoryWhere\MapDocument\IsLocated"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;mxd = arcpy.mapping.MapDocument("This_MXD.mxd")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;layers = arcpy.mapping.ListLayers(mxd,data_frame=df)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;for lyr in layers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if(lyr.name == "remove_this_layer"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.mapping.RemoveLayer(df,lyr)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;mxd.save()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;del mxd&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;print "Done..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically what the script does is reference the MXD, point to the desired data frame, remove the desired layer based on its name, save the MXD, then delete the reference to the MXD to clear the lock on the file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Nov 2018 00:55:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/remove-layers-from-a-project-without-opening/m-p/191858#M435</guid>
      <dc:creator>StephenM</dc:creator>
      <dc:date>2018-11-03T00:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Remove layers from a project without opening</title>
      <link>https://community.esri.com/t5/arcmap-questions/remove-layers-from-a-project-without-opening/m-p/1409867#M4843</link>
      <description>&lt;P&gt;Hello, I've used your script successfully but it only works with mxd files that contains a few layers. If I try to use it with an mxd containing a lot of layers, Python IDLE crashes by showing ==== RESTART: Shell ====. Is there a workaround for this?&lt;/P&gt;&lt;P&gt;I'm currently trying to remove the Basemap layer for my main MXD since it's causing my ArcGIS 10.8.1 to crash whenever I try to open it. I've already disabled GPU acceleration, but haven't worked so far.&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 18:27:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/remove-layers-from-a-project-without-opening/m-p/1409867#M4843</guid>
      <dc:creator>niftymaker</dc:creator>
      <dc:date>2024-04-15T18:27:09Z</dc:date>
    </item>
  </channel>
</rss>

