<?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 Automate Changing Mosaic Dataset Definition query with ArcPy in ArcGISPro in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/automate-changing-mosaic-dataset-definition-query/m-p/705271#M54581</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a mosaic dataset with 10 images with different Acquistion Dates. I want to populate a layout with a time-lapse series of images, so that I can show how an area changes over time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written the following code to Make a new image layer&amp;nbsp;by querying&amp;nbsp;the Mosaic Dataset's Footprint for a specific acquisition date.&lt;/P&gt;&lt;P&gt;#initialize arcpy and create project / map objects&lt;/P&gt;&lt;P&gt;import arcpy&amp;nbsp;&lt;BR /&gt;aprx=arcpy.mp.ArcGISProject("Current")&lt;BR /&gt;cmap=aprx.activeMap()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#get unique values from field&lt;/P&gt;&lt;P&gt;def unique_values(table, field): #returns all the unique values in a field&lt;BR /&gt;&amp;nbsp; &amp;nbsp; with arcpy.da.SearchCursor(table, [field]) as cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return sorted({row[0] for row in cursor})&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vals=unique_values("S_Mosaic_Vendor_ComSat\\Footprint","Acquisition_Date") # Grab the unique acquisition dates&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Create new raster layer from Definition Query&amp;nbsp;&lt;/P&gt;&lt;P&gt;def_query = "Acquisition_Date = timestamp '" + vals[5].strftime("%Y-%m-%d %H:%M:%S")+"'" #definition query string&lt;BR /&gt;lyr_name="Image_"+vals[5].strftime("%b-%d-%Y") #layer name string&lt;BR /&gt;arcpy.MakeFeatureLayer_management('&lt;SPAN&gt;S_&lt;/SPAN&gt;&lt;SPAN&gt;Mosaic_Vendor&lt;/SPAN&gt;&lt;SPAN&gt;_ComSat&lt;/SPAN&gt;\\Footprint',lyr_name,def_query)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is I only get the first image date to show up regardless of what Date I query for. Am I missing something or is this part of ArcPy still buggy? I am running ArcPro 2.3.4. I am going to try upgrading to 2.4 next week.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Sep 2019 18:20:38 GMT</pubDate>
    <dc:creator>MichaelWallace3</dc:creator>
    <dc:date>2019-09-06T18:20:38Z</dc:date>
    <item>
      <title>Automate Changing Mosaic Dataset Definition query with ArcPy in ArcGISPro</title>
      <link>https://community.esri.com/t5/python-questions/automate-changing-mosaic-dataset-definition-query/m-p/705271#M54581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a mosaic dataset with 10 images with different Acquistion Dates. I want to populate a layout with a time-lapse series of images, so that I can show how an area changes over time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written the following code to Make a new image layer&amp;nbsp;by querying&amp;nbsp;the Mosaic Dataset's Footprint for a specific acquisition date.&lt;/P&gt;&lt;P&gt;#initialize arcpy and create project / map objects&lt;/P&gt;&lt;P&gt;import arcpy&amp;nbsp;&lt;BR /&gt;aprx=arcpy.mp.ArcGISProject("Current")&lt;BR /&gt;cmap=aprx.activeMap()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#get unique values from field&lt;/P&gt;&lt;P&gt;def unique_values(table, field): #returns all the unique values in a field&lt;BR /&gt;&amp;nbsp; &amp;nbsp; with arcpy.da.SearchCursor(table, [field]) as cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return sorted({row[0] for row in cursor})&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vals=unique_values("S_Mosaic_Vendor_ComSat\\Footprint","Acquisition_Date") # Grab the unique acquisition dates&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Create new raster layer from Definition Query&amp;nbsp;&lt;/P&gt;&lt;P&gt;def_query = "Acquisition_Date = timestamp '" + vals[5].strftime("%Y-%m-%d %H:%M:%S")+"'" #definition query string&lt;BR /&gt;lyr_name="Image_"+vals[5].strftime("%b-%d-%Y") #layer name string&lt;BR /&gt;arcpy.MakeFeatureLayer_management('&lt;SPAN&gt;S_&lt;/SPAN&gt;&lt;SPAN&gt;Mosaic_Vendor&lt;/SPAN&gt;&lt;SPAN&gt;_ComSat&lt;/SPAN&gt;\\Footprint',lyr_name,def_query)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is I only get the first image date to show up regardless of what Date I query for. Am I missing something or is this part of ArcPy still buggy? I am running ArcPro 2.3.4. I am going to try upgrading to 2.4 next week.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2019 18:20:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automate-changing-mosaic-dataset-definition-query/m-p/705271#M54581</guid>
      <dc:creator>MichaelWallace3</dc:creator>
      <dc:date>2019-09-06T18:20:38Z</dc:date>
    </item>
  </channel>
</rss>

