<?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: Creating a selection, storying in memory and counting the number of selection does not work in python in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1345460#M74807</link>
    <description>&lt;P&gt;Thanks for your hint! I updated my post and now the code should be properly formated.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Nov 2023 10:41:49 GMT</pubDate>
    <dc:creator>NadjaHertel</dc:creator>
    <dc:date>2023-11-03T10:41:49Z</dc:date>
    <item>
      <title>Creating a selection, storying in memory and counting the number of selection does not work in python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1345045#M74771</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am working with a Python Notebook in ArcGis Pro 3.0.5. I would like to create a map series with tables. Every step should be done in Python.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code so far:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Laoding the libraries
import arcpy
import os
import sys

# Reference the current project, MUST be run in the ArcGIS Pro application
aprx = arcpy.mp.ArcGISProject('current')

# Reference the appropriate map and layout
m = aprx.listMaps("Map")[0]

# Reference the appropriate layout
lyt = aprx.listLayouts("Gemeinden_2023")[0]


# Storing map layers on different variables
countyLayer = aprx.listMaps()[0].listLayers("Projekte")[0]
queryLayer = aprx.listMaps()[0].listLayers("Projekte")[0]
geplanteKUBA = aprx.listMaps()[0].listLayers("KUBA_SV")[0]
geplanteKS = aprx.listMaps()[0].listLayers("Projektideen")[0] 
gemeindeLayer = aprx.listMaps()[0].listLayers("Gemeinden")[0]

state = arcpy.GetParameterAsText(0)

# Reference page layout elements
for elm in lyt.listElements():
    if elm.name == "NoGrowth": noGrowth = elm
    if elm.name == "NoMassnahmen": noMassnahmen = elm
    #if elm.name == "horzLine": horzLine = elm
    #if elm.name == "vertLine": vertLine = elm
    if elm.name == "cellTxt":  cellTxt = elm
    if elm.name == "cell2Txt": cell2Txt = elm
    if elm.name == "headerTxt": headerTxt = elm
    if elm.name == "header2Txt": header2Txt = elm
    if elm.name == "cellTxtRight": cellTxtRight = elm
    if elm.name == "cell2TxtRight": cell2TxtRight = elm
    if elm.name == "LaufendeProjekte": titelTxt = elm

# Delete elements in the layout that contain 'clone' in their name - clean up before next page
for elm in lyt.listElements("GRAPHIC_ELEMENT", "*clone*"):
    elm.delete()
for elm in lyt.listElements("TEXT_ELEMENT", "*clone*"):
    elm.delete()

# Defining the element positions
noGrowth.elementPositionX = -10
noMassnahmen.elementPositionX = -10
cellTxt.elementPositionX = -3
cell2Txt.elementPositionX = -3
headerTxt.elementPositionX = -3
header2Txt.elementPositionX = -3
#horzLine.elementPositionX = -17
#vertLine.elementPositionX = -3
cellTxtRight.elementPositionX = -2
cell2TxtRight.elementPositionX = -2
titelTxt.elementPositionX = -10

#Reference DDP object
ms = lyt.mapSeries

#Graphic table variable values
tableHeight = 4
table2Height = 3.5
tableWidth = 15
headerHeight = 0.4
titelHeight = 0.5
rowHeight = 0.4
upperX = 16.2
upperY = 9
upper2Y = 4.5

# Get the state name from the dropdown list
stateName = state
arcpy.AddMessage("Processing: "+ stateName)

# Deleting the memory
if arcpy.Exists("in_memory\select1"):
  arcpy.Delete_management("in_memory\select1")
if arcpy.Exists("in_memory\sort1"):
  arcpy.Delete_management("in_memory\sort1")
if arcpy.Exists("in_memory\select2"):
  arcpy.Delete_management("in_memory\select2")
if arcpy.Exists("in_memory\select3"):
  arcpy.Delete_management("in_memory\select3")

# Creating the first selection set
where_clause = "\"ZZGEMEINDE\" LIKE '" + stateName + "%'"
arcpy.Select_analysis(countyLayer, "in_memory\select1", where_clause)
numRecords = int(arcpy.GetCount_management("in_memory\select1").getOutput(0))

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well, and that is the error message, which I get:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;ExecuteError&lt;/SPAN&gt;                              Traceback (most recent call last)
In  &lt;SPAN class=""&gt;[10]&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;4&lt;/SPAN&gt;:     numRecords = &lt;SPAN class=""&gt;int&lt;/SPAN&gt;(arcpy.GetCount_management(&lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;in_memory&lt;/SPAN&gt;&lt;SPAN class=""&gt;\&lt;/SPAN&gt;&lt;SPAN class=""&gt;select1&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;).getOutput(&lt;SPAN class=""&gt;0&lt;/SPAN&gt;))

File &lt;SPAN class=""&gt;C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py&lt;/SPAN&gt;, in &lt;SPAN class=""&gt;GetCount&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;22757&lt;/SPAN&gt;: &lt;SPAN class=""&gt;raise&lt;/SPAN&gt; e

File &lt;SPAN class=""&gt;C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py&lt;/SPAN&gt;, in &lt;SPAN class=""&gt;GetCount&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;22754&lt;/SPAN&gt;: retval = convertArcObjectToPythonObject(gp.GetCount_management(*gp_fixargs((in_rows,), &lt;SPAN class=""&gt;True&lt;/SPAN&gt;)))

File &lt;SPAN class=""&gt;C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py&lt;/SPAN&gt;, in &lt;SPAN class=""&gt;&amp;lt;lambda&amp;gt;&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;512&lt;/SPAN&gt;:   &lt;SPAN class=""&gt;return&lt;/SPAN&gt; &lt;SPAN class=""&gt;lambda&lt;/SPAN&gt; *args: val(*gp_fixargs(args, &lt;SPAN class=""&gt;True&lt;/SPAN&gt;))

&lt;SPAN class=""&gt;ExecuteError&lt;/SPAN&gt;: Failed to execute. Parameters are not valid.
ERROR 000732: Input Rows: Dataset in_memory\select1 does not exist or is not supported
Failed to execute (GetCount).&lt;/PRE&gt;&lt;P&gt;I don't get the error because everything seems correct for me (well it isn't, but yeah)....&lt;/P&gt;&lt;P&gt;Please help me to find a solution, I would be very thankful.&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Nadja&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 10:37:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1345045#M74771</guid>
      <dc:creator>NadjaHertel</dc:creator>
      <dc:date>2023-11-03T10:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a selection, storying in memory and counting the number of selection does not work in python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1345324#M74793</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;will help by properly formatting and providing line numbers for reference&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 22:46:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1345324#M74793</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-11-02T22:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a selection, storying in memory and counting the number of selection does not work in python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1345460#M74807</link>
      <description>&lt;P&gt;Thanks for your hint! I updated my post and now the code should be properly formated.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 10:41:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1345460#M74807</guid>
      <dc:creator>NadjaHertel</dc:creator>
      <dc:date>2023-11-03T10:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a selection, storying in memory and counting the number of selection does not work in python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1345461#M74808</link>
      <description>&lt;P&gt;In lines 77-78 you check to see if select1 exists, and if it does, then you delete it&lt;/P&gt;&lt;P&gt;In lines 87- you try to do a count of select1&lt;/P&gt;&lt;P&gt;But... if it existed, then it was deleted, so trying to do a Select_analysis and a count on it doesn't make sense to me&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 10:57:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1345461#M74808</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-11-03T10:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a selection, storying in memory and counting the number of selection does not work in python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1346560#M74922</link>
      <description>&lt;P&gt;Thanks for that! Yep, this was the problem - I never defined the variable select1, and additionally, I deleted it. With defining a new select1 variable after deleting, the script works know. Many thanks :))&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 08:29:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/creating-a-selection-storying-in-memory-and/m-p/1346560#M74922</guid>
      <dc:creator>NadjaHertel</dc:creator>
      <dc:date>2023-11-07T08:29:37Z</dc:date>
    </item>
  </channel>
</rss>

