<?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 class in New to GIS Questions</title>
    <link>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231705#M613</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have any&amp;nbsp;spatial information in the txt file such as latitude and longitude?&amp;nbsp; If not, are you joining to join this data to a feature class that does have spatial information?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 21 Mar 2020 15:02:29 GMT</pubDate>
    <dc:creator>MichaelVolz</dc:creator>
    <dc:date>2020-03-21T15:02:29Z</dc:date>
    <item>
      <title>creating class</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231702#M610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi guys, is anybody can help me with this?&lt;/P&gt;&lt;P&gt;Consider a text file called trees.txt with different fields called Block, Plot, Species and DBH, separated by spaces. Every record represents one tree. DBH is the trunk diameter at 4.5 feet from the ground. Create a script with a tree class with the following properties: Block, Plot, Species and DBH. The class should also have one method: diameter inside bark, calculated as DIB = DBH * (1/1.09). Once the class has been created, use the class to create tree objects by reading the data from the text file. The script should print the following: Report Tree 1&lt;/P&gt;&lt;P&gt;Block:&lt;/P&gt;&lt;P&gt;Plot:&lt;/P&gt;&lt;P&gt;Species:&lt;/P&gt;&lt;P&gt;DBH:&lt;/P&gt;&lt;P&gt;DIB:&lt;/P&gt;&lt;P&gt;Report Tree 2&lt;/P&gt;&lt;P&gt;Block:&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2020 22:12:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231702#M610</guid>
      <dc:creator>CNRFGN</dc:creator>
      <dc:date>2020-03-20T22:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: creating class</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231703#M611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi CRNF,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you clarify what you want the output to be and what your input is?&amp;nbsp; Are you starting with a text file or you are looking for a script to produce a text file from a feature class/shapefile/etc?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2020 23:22:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231703#M611</guid>
      <dc:creator>ChristopherBertrand</dc:creator>
      <dc:date>2020-03-20T23:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: creating class</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231704#M612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;start with the text file trees.txt with&lt;SPAN style="background-color: #ffffff;"&gt;w different fields called Block, Plot, Species and DBH, separated by spaces.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Mar 2020 14:49:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231704#M612</guid>
      <dc:creator>CNRFGN</dc:creator>
      <dc:date>2020-03-21T14:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: creating class</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231705#M613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have any&amp;nbsp;spatial information in the txt file such as latitude and longitude?&amp;nbsp; If not, are you joining to join this data to a feature class that does have spatial information?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Mar 2020 15:02:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231705#M613</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2020-03-21T15:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: creating class</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231706#M614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume this is related to your &lt;A _jive_internal="true" href="https://community.esri.com/thread/250212-python-functions-and-classes" target="_blank"&gt;question about Exercise 12&lt;/A&gt;.&amp;nbsp; The parcel class script used in that exercise can be used as a pattern to create a tree class.&amp;nbsp; Once the class is created, then you would come up with a way to read the lines in the text file.&amp;nbsp; Here is the parcel class example:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;class&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;Parcel&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;__init__&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;self&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; landuse&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; value&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;landuse &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; landuse
        self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;value &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; value
        
    &lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;assessment&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;self&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;landuse &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SFR"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            rate &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.05&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;elif&lt;/SPAN&gt; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;landuse &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"MFR"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            rate &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.04&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            rate &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.02&lt;/SPAN&gt;
        assessment &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;value &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; rate
        &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; assessment‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;OL&gt;&lt;LI&gt;In line 1 change Parcel to Tree.&lt;/LI&gt;&lt;LI&gt;In lines 2, 3 and 4, replace landuse and value with block, plot, species and dbh. (You'll be adding a couple of new lines in this section.)&lt;/LI&gt;&lt;LI&gt;In lines 6, 13 and 14, replace assessment with dib.&lt;/LI&gt;&lt;LI&gt;In line 13, replace value with dbh, and replace rate&amp;nbsp; with your numeric value.&lt;/LI&gt;&lt;LI&gt;Delete lines 7 thru 12 in above script (landuse and rate section).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Share the script you come up with.&amp;nbsp; The next steps would be to read the text file, split each line where there are spaces, use the data to create a tree class, and print the results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:44:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231706#M614</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T11:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: creating class</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231707#M615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;class Tree:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self, block, plot, species, dbh):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.block = block&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.plot=plot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.species=species&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.dbh=dbh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def dib(self):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dib = self.dbh * 1/1.09&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return dib&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Mar 2020 21:32:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231707#M615</guid>
      <dc:creator>CNRFGN</dc:creator>
      <dc:date>2020-03-21T21:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: creating class</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231708#M616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your tree class looks good, with one possible exception.&amp;nbsp; The next to last line appears to need indentation.&amp;nbsp; When sharing Python scripts, it is good to use the "syntax highlighter" when posting to GeoNet.&amp;nbsp; There are some good instructions on using the highlighter here: &lt;A _jive_internal="true" href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting" target="_blank"&gt;Code Formatting... the basics++ &lt;/A&gt;Here is what your code looks like using the highlighter with the indentation corrected:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;class Tree:
    def __init__(self, block, plot, species, dbh):
        self.block = block
        self.plot=plot
        self.species=species
        self.dbh=dbh    

    def dib(self):
        dib = self.dbh * (1/1.09) # 1/1.09 = 0.917431193
        return dib
‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Also in line 9, I added some parenthesis around the 1/1.09.&amp;nbsp; I don't think it matters in this case, but it insures the division happens before the multiplication.&amp;nbsp; You could also use the 0.91743 equivalent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the next step, you will need some code to read your text file.&amp;nbsp; Here's a basic approach.&amp;nbsp; It assumes the text file does not have a header.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;filename &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\Path\to\trees.txt"&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# enter full path and filename&lt;/SPAN&gt;
tf &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;filename&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'r'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

treeData &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; tf&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;readlines&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; treeData&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    td &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# strip any line feeds, then split on spaces&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; td

tf&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;close&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I created a simple tree data file, and the script prints out:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;['1', '1', 'cedar', '4.5']
['1', '2', 'spruce', '3.75']
['2', '1', 'hemlock', '2.5']&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Note that a list is produced and all the elements are text (in quotes).&amp;nbsp; It is possible that the Block and Plot will be text, but they could be numbers.&amp;nbsp; The DBH data is probably a floating point number, so you will need to change it from type text to float.&amp;nbsp; The next steps are to include the tree class and print the results.&amp;nbsp; This should be similar to your parcels&amp;nbsp; example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may need to deal with a header row when reading your text file.&amp;nbsp; If you were wanting to number each tree by row in the file, you will need a counter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know how this part goes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:44:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231708#M616</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T11:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: creating class</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231709#M617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you i think from this i can handle it. i appreciate it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Mar 2020 00:24:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/creating-class/m-p/231709#M617</guid>
      <dc:creator>CNRFGN</dc:creator>
      <dc:date>2020-03-22T00:24:45Z</dc:date>
    </item>
  </channel>
</rss>

