<?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: Help calling a table attribute, and using it as a variable? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413747#M32573</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you to both of you, the answers worked perfectly.&amp;nbsp; The Extract by attribute tool however created more questions than it answered.&amp;nbsp; I appreciate your inputs and am looking forward to investigating the Con function.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Jun 2013 20:29:44 GMT</pubDate>
    <dc:creator>TomKearns</dc:creator>
    <dc:date>2013-06-20T20:29:44Z</dc:date>
    <item>
      <title>Help calling a table attribute, and using it as a variable?</title>
      <link>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413744#M32570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a table with multiple min and a max numbers for multiple points.&amp;nbsp; I would like to use "Extract by Attribute" to pull the fitting areas from a DEM which corresponds to each area. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Reworded: I would like to pull all the raster cells which fall inside the ranges provided for each specific area by calling the table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Object&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Area1Min&amp;nbsp; Area1Max&amp;nbsp; Area2Min Area2Max&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; A1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1500&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 750&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1200&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; A2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 900&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1700&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1200&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1500&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using this example I would create four new rasters of A1 in Area1, A1 in Area2...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am having trouble setting up the variable which would be used in the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;attExtract = ExtractByAttributes("elevation", "VALUE &amp;gt; 1000") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;attExtract.save("c:/sapyexamples/output/attextract")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know this code works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;attExtract = ExtractByAttributes("dem", "VALUE &amp;gt; 1000 AND VALUE &amp;lt; 1500")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to replace the 1000 and 1500 with a call to the places Area1Min and Area1Max for A1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 21:56:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413744#M32570</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2013-06-19T21:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help calling a table attribute, and using it as a variable?</title>
      <link>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413745#M32571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have a table with multiple min and a max numbers for multiple points.&amp;nbsp; I would like to use "Extract by Attribute" to pull the fitting areas from a DEM which corresponds to each area. &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The best way to get the variables from a table into Python is using cursors. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;rows = arcpy.SearchCursor("areatable.dbf") k = 1 for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; a1min = float(row.getValue("Area1Min")) &amp;nbsp;&amp;nbsp;&amp;nbsp; a1max = float(row.getValue("Area1Max")) &amp;nbsp;&amp;nbsp;&amp;nbsp; where = "VALUE &amp;gt; {0}&amp;nbsp; AND VALUE &amp;lt; {1}".format(a1min, a1max) &amp;nbsp;&amp;nbsp;&amp;nbsp; dem1 = ExtractByAttributes(Raster("dem"), where) &amp;nbsp;&amp;nbsp;&amp;nbsp; dem1.save("dema{}".format(k)) # save as grids dema1, dema2 del row, rows&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead of ExtractByAttributes you could use the Con function like this. This is more of an Arcpy approach really:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;dem = Raster("dem1") dem1 = Con(dem &amp;gt; a1min and dem &amp;lt; a1max, dem)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 22:22:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413745#M32571</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-06-19T22:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help calling a table attribute, and using it as a variable?</title>
      <link>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413746#M32572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I believe you're looking for a &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000050000000"&gt;SearchCursor&lt;/A&gt;&lt;SPAN&gt; to loop through your rows, then getValue(FIELDNAME) to read the individual value (see the first example in the link). You'll need four getValues (one for each field) and two ExtractByAttributes (one each for Area1 and Area2) in your search cursor loop.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 22:25:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413746#M32572</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2013-06-19T22:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Help calling a table attribute, and using it as a variable?</title>
      <link>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413747#M32573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you to both of you, the answers worked perfectly.&amp;nbsp; The Extract by attribute tool however created more questions than it answered.&amp;nbsp; I appreciate your inputs and am looking forward to investigating the Con function.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jun 2013 20:29:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413747#M32573</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2013-06-20T20:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help calling a table attribute, and using it as a variable?</title>
      <link>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413748#M32574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The Extract by attribute tool however created more questions than it answered.&amp;nbsp; &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did the string substitution to create the SQL expression throw you for a loop? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
where = "VALUE &amp;gt; " + str(a1min) + " AND VALUE &amp;lt; " + str(a1max)
where = "VALUE &amp;gt; {0}&amp;nbsp; AND VALUE &amp;lt; {1}".format(a1min, a1max)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These expressions are equivalent, they both evaluate to something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;VALUE &amp;gt; 5000 AND VALUE &amp;lt; 6000&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I like to promote the use of string substitution because it makes the SQL expression setup much easier to read and debug.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:45:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413748#M32574</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T18:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help calling a table attribute, and using it as a variable?</title>
      <link>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413749#M32575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for asking but the string was perfect, I already had mine built in the same fashion so it was an easy substitution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The tool turns out a raster with no "values".&amp;nbsp; While they can be displayed, they are incredibly large files and can not be converted to a shape file due to not having any data attached.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Con however, worked extremely well and the Raster To Polygon tool was easy to add on to the end of my script. It was an awesome suggestion.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jun 2013 22:19:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413749#M32575</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2013-06-20T22:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help calling a table attribute, and using it as a variable?</title>
      <link>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413750#M32576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; The tool turns out a raster with no "values".&amp;nbsp; While they can be displayed, they are incredibly large files and can not be converted to a shape file due to not having any data attached.&amp;nbsp; &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If polygons are what you want, you would need to do something like this to create an integer grid of all non-null cells, and then convert that to polygons:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
dem1 = SetNull(IsNull(ExtractByAttributes(Raster("dem"), where)),1)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:45:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calling-a-table-attribute-and-using-it-as-a/m-p/413750#M32576</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T18:45:54Z</dc:date>
    </item>
  </channel>
</rss>

