<?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: Cannot Delete Locked .tif.aux.xml File Generated by ApplySymbologyFromLayer in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622314#M96495</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/618314"&gt;@JonM32&lt;/a&gt;&amp;nbsp;thank you very much for your reply.&lt;/P&gt;&lt;P&gt;1. I tried it by ArcGIS 3.4. .tif.aux.xml file could not be removed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I have tried 100 tif files, all the 100 xml file could not be removed.&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jun 2025 15:09:38 GMT</pubDate>
    <dc:creator>WentaoChe</dc:creator>
    <dc:date>2025-06-10T15:09:38Z</dc:date>
    <item>
      <title>Cannot Delete Locked .tif.aux.xml File Generated by ApplySymbologyFromLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1621772#M96443</link>
      <description>&lt;P&gt;&lt;SPAN&gt;After using the ArcGIS Pro tool &lt;/SPAN&gt;&lt;STRONG&gt;arcpy.management.ApplySymbologyFromLayer()&lt;/STRONG&gt;&lt;SPAN&gt; to apply symbology to a &lt;/SPAN&gt;&lt;SPAN&gt;.tif&lt;/SPAN&gt;&lt;SPAN&gt; raster file, a corresponding &lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;.tif.aux.xml&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt; file is automatically generated. However, I'm unable to delete this &lt;/SPAN&gt;&lt;SPAN&gt;.tif.aux.xml&lt;/SPAN&gt;&lt;SPAN&gt; file because it appears locked.&amp;nbsp; I tried os.remove, but it does not work. I am using &lt;STRONG&gt;ArcGIS Pro 3.5. &lt;/STRONG&gt;Is there a way to delete this xml file?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here are the code lines:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os, glob

# DEM_tif_Folder = arcpy.GetParameterAsText(0)

DEM_tif_Folder = r'D:\20250305-CS-Map-Tool\DEM_tif_Folder'

cs_dem_lyrx = os.path.join(DEM_tif_Folder, 'DEM_Sample.tif.lyrx')

os.chdir(DEM_tif_Folder)
arcpy.env.workspace = DEM_tif_Folder

arcpy.env.overwriteOutput = True
arcpy.env.pyramid = None
arcpy.env.rasterStatistics = None

[os.remove(x) for x in arcpy.ListFiles('*.xml')]

aprx = arcpy.mp.ArcGISProject('current')

m = aprx.listMaps()[0]

for lyr in m.listLayers():
  m.removeLayer(lyr)

tif = 'DEM2356.tif'

full_tif = os.path.join(DEM_tif_Folder, tif)
m.addDataFromPath(full_tif)
tif_layer = m.listLayers()[0]
results = arcpy.management.ApplySymbologyFromLayer(tif_layer, cs_dem_lyrx)

out_aprx = DEM_tif_Folder + os.sep + 'tmp_dem_tif.aprx'
aprx.saveACopy(out_aprx)
 
for lyr in m.listLayers():
  m.removeLayer(lyr)
  
aprx.deleteItem(aprx.listMaps()[0])

del aprx
del m

# time.sleep(9)

xml_file = tif + '.aux.xml'
if os.path.exists(DEM_tif_Folder + os.sep + xml_file):
  os.remove(xml_file)

for file in os.listdir():
  if file.endswith('.tif.aux.xml'):
    arcpy.AddMessage('    %s: ' % file)
    os.remove(file)

os.system('del *.tif.aux.xml')&lt;/LI-CODE&gt;&lt;P&gt;Here are the contents of DEM2356.tif.aux.xml:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;lt;PAMDataset&amp;gt;
  &amp;lt;PAMRasterBand band="1"&amp;gt;
    &amp;lt;Histograms&amp;gt;
      &amp;lt;HistItem&amp;gt;
        &amp;lt;HistMin&amp;gt;159.64497375488&amp;lt;/HistMin&amp;gt;
        &amp;lt;HistMax&amp;gt;357.10797119141&amp;lt;/HistMax&amp;gt;
        &amp;lt;BucketCount&amp;gt;256&amp;lt;/BucketCount&amp;gt;
        &amp;lt;IncludeOutOfRange&amp;gt;1&amp;lt;/IncludeOutOfRange&amp;gt;
        &amp;lt;Approximate&amp;gt;0&amp;lt;/Approximate&amp;gt;
        &amp;lt;HistCounts&amp;gt;34|190|325|362|425|488|580|761|743|820|877|908|1223|1308|1309|1361|1560|1606|1709|1673|1834|1859|1931|1981|2011|2083|2105|2232|2196|2271|2419|2487|2480|2468|2500|2601|2653|2712|2844|2932|2903|2931|3043|3037|3116|3100|3134|3194|3278|3295|3319|3392|3464|3532|3674|3685|3685|3670|3718|3812|3870|3877|3920|3969|4074|4189|4182|4365|4491|4377|4481|4582|4706|4672|4706|4782|4802|4801|4879|4866|4853|4876|5000|5057|5044|5125|5119|5161|5195|5296|5333|5350|5386|5534|5568|5625|5728|5710|5749|5775|5806|5771|5829|5927|6003|6025|6113|6071|6120|6053|6117|6156|6162|6139|6173|6069|6089|6119|6156|6147|6157|6226|6314|6238|6319|6328|6299|6244|6288|6313|6202|6251|6213|6258|6291|6349|6341|6345|6240|6179|6191|6183|6094|6308|6204|6218|6165|6286|6120|6051|6037|5956|5783|5760|5776|5752|5670|5634|5704|5473|5462|5353|5247|5298|5261|5161|5243|5187|5117|5121|5308|5283|5380|5201|4811|4529|4462|4428|4460|4284|4306|4178|4035|4068|3970|3840|3654|3663|3690|3580|3558|3288|3224|3375|3595|3218|3571|3209|3359|2978|3106|2987|2993|2903|2766|2502|2441|2310|2142|1958|1887|1918|2021|2228|2329|2308|2220|1939|2157|2094|1528|1398|1308|1319|1239|1073|1080|1023|1059|1081|1137|1156|692|741|629|563|521|503|461|443|419|375|349|321|314|275|216|134|124|126|127|110|108|93|67|1&amp;lt;/HistCounts&amp;gt;
      &amp;lt;/HistItem&amp;gt;
    &amp;lt;/Histograms&amp;gt;
  &amp;lt;/PAMRasterBand&amp;gt;
&amp;lt;/PAMDataset&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 07:28:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1621772#M96443</guid>
      <dc:creator>WentaoChe</dc:creator>
      <dc:date>2025-06-09T07:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Delete Locked .tif.aux.xml File Generated by ApplySymbologyFromLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1621836#M96451</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1475"&gt;@WentaoChe&lt;/a&gt;&amp;nbsp;Maybe the raster needs that file for display since it looks like a statistics file that holds information needed for symbology. So by default, Pro won't let you delete it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, you could always try finding the file in the file explorer and try manually deleting it.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 14:43:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1621836#M96451</guid>
      <dc:creator>JonM32</dc:creator>
      <dc:date>2025-06-09T14:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Delete Locked .tif.aux.xml File Generated by ApplySymbologyFromLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622046#M96464</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/618314"&gt;@JonM32&lt;/a&gt;&amp;nbsp;Thank you very much for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;After using &lt;STRONG&gt;ApplySymbologyFromLayer()&lt;/STRONG&gt;, I add a contour shapefile on top of the DEM .tif and then use &lt;STRONG&gt;exportToPNG&lt;/STRONG&gt; to export the final map. At that point, my processing is complete, and there is no need to retain the .xml statistics file used for symbology. Since I have thousands of .tif files to process, I need an automated way to remove these .xml files rather than manually deleting them.&lt;/P&gt;&lt;P&gt;Although I could use another tool to remove them afterward, it feels inefficient. Is there a better approach within ArcGIS Pro to handle this automatically?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 21:33:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622046#M96464</guid>
      <dc:creator>WentaoChe</dc:creator>
      <dc:date>2025-06-09T21:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Delete Locked .tif.aux.xml File Generated by ApplySymbologyFromLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622118#M96469</link>
      <description>&lt;P&gt;The results object or&amp;nbsp;tif_layer vars may be holding a reference the dataset causing a lock on the xml.&amp;nbsp; Try cleaning those up (del results etc)&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 01:27:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622118#M96469</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2025-06-10T01:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Delete Locked .tif.aux.xml File Generated by ApplySymbologyFromLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622123#M96470</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10780"&gt;@Luke_Pinner&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;SPAN&gt;Thank you very much for your reply.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I tried deleting the &lt;STRONG&gt;results&lt;/STRONG&gt; object and &lt;STRONG&gt;tif_layer&lt;/STRONG&gt; variables, but the .tif.aux.xml file is still locked and could not be removed using &lt;STRONG&gt;os.remove&lt;/STRONG&gt;(xml_file).&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 01:48:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622123#M96470</guid>
      <dc:creator>WentaoChe</dc:creator>
      <dc:date>2025-06-10T01:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Delete Locked .tif.aux.xml File Generated by ApplySymbologyFromLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622266#M96488</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1475"&gt;@WentaoChe&lt;/a&gt;&amp;nbsp;Anytime - in terms of a better approach: I can't speak to an automated solution to delete them but in terms of troubling shooting I would try the ideas below.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Try this process on an older version of Pro (3.4 or 3.3) and see if it occurs still. Maybe it's a bug in 3.5?&lt;/LI&gt;&lt;LI&gt;Try this process on different tifs to see if it's isolated to one specific DEM or all of them&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Tue, 10 Jun 2025 13:10:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622266#M96488</guid>
      <dc:creator>JonM32</dc:creator>
      <dc:date>2025-06-10T13:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Delete Locked .tif.aux.xml File Generated by ApplySymbologyFromLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622314#M96495</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/618314"&gt;@JonM32&lt;/a&gt;&amp;nbsp;thank you very much for your reply.&lt;/P&gt;&lt;P&gt;1. I tried it by ArcGIS 3.4. .tif.aux.xml file could not be removed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I have tried 100 tif files, all the 100 xml file could not be removed.&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 15:09:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1622314#M96495</guid>
      <dc:creator>WentaoChe</dc:creator>
      <dc:date>2025-06-10T15:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Delete Locked .tif.aux.xml File Generated by ApplySymbologyFromLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1643073#M98320</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10780"&gt;@Luke_Pinner&lt;/a&gt;, After some trial and error, I found a workaround to delete the .tif.aux.xml file:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. Copy&amp;nbsp;'DEM2356.tif' to 'tmp_dem.tif'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Excute arcpy.management.ApplySymbologyFromLayer(tif_layer, cs_dem_lyrx)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3.&amp;nbsp;Excute arcpy.management.Delete('tmp_dem.tif')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4. Excute &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;arcpy.management.Delete('tmp_dem.tif')&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Deleting 'tmp_dem.tif' twice removes the 'tmp_dem.tif.aux.xml' file. It worked, but I don't know why.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Wentao Che&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Aug 2025 00:02:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/cannot-delete-locked-tif-aux-xml-file-generated-by/m-p/1643073#M98320</guid>
      <dc:creator>WentaoChe</dc:creator>
      <dc:date>2025-08-19T00:02:16Z</dc:date>
    </item>
  </channel>
</rss>

