<?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: Using a Variable for the Class Code parameter in Change LAS Class Codes Arcpy Script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253686#M66744</link>
    <description>&lt;P&gt;teste&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2023 07:12:25 GMT</pubDate>
    <dc:creator>leandroduartebr</dc:creator>
    <dc:date>2023-02-01T07:12:25Z</dc:date>
    <item>
      <title>Using a Variable for the Class Code parameter in Change LAS Class Codes Arcpy Script</title>
      <link>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253579#M66741</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I've been racking my brain as to why this isn't working. Basically I have a script to process LiDAR .las data and I have a step to "Change LAS Class Code". And eventually I want to have this in a GP Script Tool or as a Notebook where my coworker(s) just need to put in the inputs.&lt;/P&gt;&lt;P&gt;Per the documentation for the Change LAS Class Code tool, the input format for "class_codes" can be&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;For example, a current class code of 5 can be changed to 25 by specifying&amp;nbsp;&lt;STRONG&gt;&lt;SPAN class=""&gt;"5 2"&lt;/SPAN&gt;&amp;nbsp;or&amp;nbsp;&lt;SPAN class=""&gt;[[5, 2]]&lt;/SPAN&gt;&lt;/STRONG&gt;. Likewise, a change to the synthetic class flag can be made by adding the keyword for the desired modification &lt;STRONG&gt;(&lt;SPAN class=""&gt;"5 2 SET"&lt;/SPAN&gt;&amp;nbsp;or&amp;nbsp;&lt;SPAN class=""&gt;[[5, 2, "SET"]]&lt;/SPAN&gt;)&lt;/STRONG&gt;. Multiple changes can be specified as a semicolon-delimited string (for example,&amp;nbsp;&lt;SPAN class=""&gt;"&lt;STRONG&gt;5 2; 8 3; 1 4"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;)&lt;/STRONG&gt; or as a list of lists (for example,&lt;STRONG&gt;&amp;nbsp;&lt;SPAN class=""&gt;[[5, 2], [8, 3], [1, 4]]&lt;/SPAN&gt;&lt;/STRONG&gt;).&amp;nbsp;&amp;nbsp;&lt;A title="Change LAS Class Codes (3D Analyst)" href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/3d-analyst/change-las-class-codes.htm" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/3d-analyst/change-las-class-codes.htm&lt;/A&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;But when I put in the Input() or&amp;nbsp;&lt;SPAN&gt;arcpy.GetParameterAsText &lt;SPAN&gt;to use as a variable&lt;/SPAN&gt;, in the same way the documentation has the change class codes formatted, the script will fail. But when I hard code it into the Geoprocessing step (ex: class_code = [[1,0]]) it works just fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Example Code&lt;/P&gt;&lt;P&gt;inputClassCodeChange = input("..."): [[0,1]]&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;arcpy.ddd.ChangeLasClassCodes(in_las_dataset = lasdsets, class_codes = inputClassCodeChange)&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;^ This will not work and fails.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But hard coding it in like, below, works just fine.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;arcpy.ddd.ChangeLasClassCodes(in_las_dataset = lasdsets, class_codes = [[0,1]])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I'm trying to figure out what I'm missing. I've tried adding quotes, and some many combinations.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I may just be dumb but any help y'all can give will be greatly apprciated.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thomas&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 22:19:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253579#M66741</guid>
      <dc:creator>twangtx</dc:creator>
      <dc:date>2023-01-31T22:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Variable for the Class Code parameter in Change LAS Class Codes Arcpy Script</title>
      <link>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253642#M66743</link>
      <description>&lt;P&gt;python 'input' uses strings&amp;nbsp;&lt;/P&gt;&lt;P&gt;did you try the&amp;nbsp;&lt;EM&gt;&lt;SPAN class=""&gt;"&lt;STRONG&gt;5 2; 8 3; 1 4" &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN class=""&gt;option and parse the input accordingly instead?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 02:37:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253642#M66743</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-02-01T02:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Variable for the Class Code parameter in Change LAS Class Codes Arcpy Script</title>
      <link>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253686#M66744</link>
      <description>&lt;P&gt;teste&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 07:12:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253686#M66744</guid>
      <dc:creator>leandroduartebr</dc:creator>
      <dc:date>2023-02-01T07:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Variable for the Class Code parameter in Change LAS Class Codes Arcpy Script</title>
      <link>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253687#M66745</link>
      <description>&lt;P&gt;teste2&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 07:14:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253687#M66745</guid>
      <dc:creator>leandroduartebr</dc:creator>
      <dc:date>2023-02-01T07:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Variable for the Class Code parameter in Change LAS Class Codes Arcpy Script</title>
      <link>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253748#M66746</link>
      <description>&lt;P&gt;If you want to keep the [[1,2]] format, you can parse it out with json.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import json

inputClassCodeChange = input()

rawString = inputClassCodeChange
rawStringType = type(rawString)

# String to list
res = json.loads(rawString)
resType = type(res)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeffK_0-1675254941098.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/61813i90DAC25FDC01120E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeffK_0-1675254941098.png" alt="JeffK_0-1675254941098.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 12:39:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253748#M66746</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-02-01T12:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Variable for the Class Code parameter in Change LAS Class Codes Arcpy Script</title>
      <link>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253813#M66749</link>
      <description>&lt;P&gt;I tried that as &lt;STRONG&gt;classcode&lt;/STRONG&gt; = input(&lt;EM&gt;&lt;SPAN class=""&gt;"&lt;STRONG&gt;5 2; 8 3; 1 4"),&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN class=""&gt;then&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;arcpy.ddd.ChangeLasClassCodes(in_las_dataset = lasdsets, class_codes = &lt;STRONG&gt;classcode&lt;/STRONG&gt;), but it would fail.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If you mean like parsing out each individual class change then putting it in a list for the script to loop through each one. I started down that path, but the documentation makes it seem like I should just be able to insert that string, as is, in the parameters and it should work.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 14:20:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253813#M66749</guid>
      <dc:creator>twangtx</dc:creator>
      <dc:date>2023-02-01T14:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Variable for the Class Code parameter in Change LAS Class Codes Arcpy Script</title>
      <link>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253815#M66750</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;I have gotten this to work (or at least not fail)!&lt;/P&gt;&lt;P&gt;One more library of tools I need to learn...&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 14:26:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-variable-for-the-class-code-parameter-in/m-p/1253815#M66750</guid>
      <dc:creator>twangtx</dc:creator>
      <dc:date>2023-02-01T14:26:33Z</dc:date>
    </item>
  </channel>
</rss>

