<?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: GetCountManagement for Mosaic Dataset in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/getcountmanagement-for-mosaic-dataset/m-p/1148132#M63874</link>
    <description>&lt;P&gt;Thanks, works nicely.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Feb 2022 19:34:29 GMT</pubDate>
    <dc:creator>KeonMonroe</dc:creator>
    <dc:date>2022-02-25T19:34:29Z</dc:date>
    <item>
      <title>GetCountManagement for Mosaic Dataset</title>
      <link>https://community.esri.com/t5/python-questions/getcountmanagement-for-mosaic-dataset/m-p/1147691#M63871</link>
      <description>&lt;P&gt;I'm trying to develop a geoprocessing tool for handling mosaic datasets. Using ArcGIS Pro - I can query a mosaic dataset and find how many primary rasters it contains. How can I replicate this behavior in a script? If I had a normal feature class I would make it a feature layer, select on the layer, then GetCount() to find the number of rows.&lt;/P&gt;&lt;P&gt;How would you do this with a mosaic dataset that contains primary and overview rasters?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def query_primary_rasters(input_md):
    """ Return the number of primary rasters in a given Mosaic dataset
    """
    arcpy.AddMessage(f"Input Mosaic Dataset:\n{input_md}")

    query_by = "Category = 1"  # primary rasters
    md_lyr = "md_lyr"
    # arcpy.MakeFeatureLayer_management(in_features=os.path.join(input_md, "Footprint"), out_layer = md_lyr, where_clause= query_by)
    # arcpy.MakeMosaicLayer_management(input_md, out_mosaic_layer= md_lyr, where_clause= query_by)
    
    # NOTE - below works but doesn't return selected row count (includes all items)
    arcpy.management.SelectLayerByAttribute(input_md, "NEW_SELECTION", query_by, None)
    count_primary = int(arcpy.GetCount_management(md_lyr)[0])

    arcpy.AddMessage(f"There are {count_primary} primary rasters in the mosaic dataset")
    return count_primary

update_md = arcpy.GetParameterAsText(0)
query_primary_rasters(update_md)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 19:43:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getcountmanagement-for-mosaic-dataset/m-p/1147691#M63871</guid>
      <dc:creator>KeonMonroe</dc:creator>
      <dc:date>2022-02-24T19:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: GetCountManagement for Mosaic Dataset</title>
      <link>https://community.esri.com/t5/python-questions/getcountmanagement-for-mosaic-dataset/m-p/1147709#M63872</link>
      <description>&lt;P&gt;It appears as if Pro's Table to Table tool will allow the mosaic as input, and let you put a query of "Category = 1".&amp;nbsp; This will output just the primary's to a new table (could probably go to memory, didn't test) that can now be fed into the GetCount tool.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 20:31:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getcountmanagement-for-mosaic-dataset/m-p/1147709#M63872</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-02-24T20:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: GetCountManagement for Mosaic Dataset</title>
      <link>https://community.esri.com/t5/python-questions/getcountmanagement-for-mosaic-dataset/m-p/1148132#M63874</link>
      <description>&lt;P&gt;Thanks, works nicely.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 19:34:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getcountmanagement-for-mosaic-dataset/m-p/1148132#M63874</guid>
      <dc:creator>KeonMonroe</dc:creator>
      <dc:date>2022-02-25T19:34:29Z</dc:date>
    </item>
  </channel>
</rss>

