<?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: python functions and classes in New to GIS Questions</title>
    <link>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350159#M902</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;parcelclass.py&lt;/P&gt;&lt;P&gt;class Parcel:&lt;BR /&gt; def _init_(self, landuse, value):&lt;BR /&gt; self.landuse = landuse&lt;BR /&gt; self.value = value&lt;/P&gt;&lt;P&gt;def assessment(self):&lt;BR /&gt; if self.landuse == "SFR":&lt;BR /&gt; rate = 0.05&lt;BR /&gt; elif self.landuse == "MFR":&lt;BR /&gt; rate = 0.04&lt;BR /&gt; else:&lt;BR /&gt; rate = 0.02&lt;BR /&gt; assessment = self.value * rate&lt;BR /&gt; return assessment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parceltax.py&lt;/P&gt;&lt;P&gt;import parcelclass&lt;BR /&gt;myparcel = parcelclass.Parcel("SFR", 125000)&lt;BR /&gt;print 'Land use: ", myparcel.landuse&lt;BR /&gt;mytax = myparcel.assessment()&lt;BR /&gt;print "Tax assessment: ", mytax&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 21 Mar 2020 15:26:34 GMT</pubDate>
    <dc:creator>CNRFGN</dc:creator>
    <dc:date>2020-03-21T15:26:34Z</dc:date>
    <item>
      <title>python functions and classes</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350156#M899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;its the challenge 2 frompython scriptinh for arcgis book. is anybody could solve this? thank you&lt;/P&gt;&lt;P&gt;You are given a feature class called parcels.shp located in the Exercise12 folder that contains the following fields: FID, Shape, Landuse, and Value. Modify the parceltax.py script so that it determines the property tax for each parcel and stores these values in a list. You should use the class created in the parcelclass.py script—the class can remain unchanged. Print the values of the final list as follows: FID:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2020 22:15:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350156#M899</guid>
      <dc:creator>CNRFGN</dc:creator>
      <dc:date>2020-03-20T22:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: python functions and classes</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350157#M900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you could add the&amp;nbsp; script to a syntax highlighter window, I'll bet you get some takers:&amp;nbsp; nothing personal but I don't open zip files.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2020 22:27:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350157#M900</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-03-20T22:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: python functions and classes</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350158#M901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The solution the author intended was to print a list of FIDs and the corresponding tax assessment; and not to create a "Python list" containing this data.&amp;nbsp; The author's solution is near the end of the PDF exercise document available on the book's webpage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The basic solution is to create a SearchCursor to read the data from a shape file, use the Parcel class to create a parcel object from each row of data, use the assessment method to calculate the tax, and then print the FID and tax amount.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Mar 2020 01:51:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350158#M901</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2020-03-21T01:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: python functions and classes</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350159#M902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;parcelclass.py&lt;/P&gt;&lt;P&gt;class Parcel:&lt;BR /&gt; def _init_(self, landuse, value):&lt;BR /&gt; self.landuse = landuse&lt;BR /&gt; self.value = value&lt;/P&gt;&lt;P&gt;def assessment(self):&lt;BR /&gt; if self.landuse == "SFR":&lt;BR /&gt; rate = 0.05&lt;BR /&gt; elif self.landuse == "MFR":&lt;BR /&gt; rate = 0.04&lt;BR /&gt; else:&lt;BR /&gt; rate = 0.02&lt;BR /&gt; assessment = self.value * rate&lt;BR /&gt; return assessment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parceltax.py&lt;/P&gt;&lt;P&gt;import parcelclass&lt;BR /&gt;myparcel = parcelclass.Parcel("SFR", 125000)&lt;BR /&gt;print 'Land use: ", myparcel.landuse&lt;BR /&gt;mytax = myparcel.assessment()&lt;BR /&gt;print "Tax assessment: ", mytax&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Mar 2020 15:26:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350159#M902</guid>
      <dc:creator>CNRFGN</dc:creator>
      <dc:date>2020-03-21T15:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: python functions and classes</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350160#M903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;makes it easy to read the code and provide feedback with line numbers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Mar 2020 15:29:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350160#M903</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-03-21T15:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: python functions and classes</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350161#M904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For &lt;STRONG&gt;Challenge 2&lt;/STRONG&gt; you have a parcel class module.&amp;nbsp; The code needs no modification; it just needs to be included in the final project:&lt;STRONG&gt; &lt;/STRONG&gt;&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;P&gt;The parcel tax script illustrates how to use the parcel class:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; parcelclass
myparcel &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; parcelclass&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Parcel&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"SFR"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;125000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Land use: "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; myparcel&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;landuse
mytax &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; myparcel&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;assessment&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Tax assessment: "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; mytax&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What is being asked is to loop through a feature and calculate the tax for each parcel based on the FID, Landuse and Value of the property.&amp;nbsp; To do this, you will use a search cursor.&amp;nbsp; The author has given an example of how to use a search cursor in exercise 7.&amp;nbsp; Review this section if needed.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcpy &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; env
env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:/EsriPress/Python/Data/Exercise07"&lt;/SPAN&gt;
fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"airports.shp"&lt;/SPAN&gt;
cursor &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"NAME"&lt;/SPAN&gt;&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; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Airport name = {0}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Since this last script is closest to the goal, modify it to read the desired data. Replace the path given in line 3 to the path for Exercise 12.&amp;nbsp; In line 3, correct the name of the shape file where the data is located.&amp;nbsp; Replace "NAME" in line 5 with the three fields needed.&amp;nbsp; Then change line 7 to print the data; this is for testing and will be replaced later.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# line 7 will become (note indentation)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"FID: {0}  Landuse: {1}  Value: {2}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Once you have this script reading your shape file correctly, the parcel class and tax scripts will be added into the mix by&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Import the parcel class by placing line 1 of the tax script at the top of your working script.&lt;/LI&gt;&lt;LI&gt;Copy lines 2 and 4 from your tax script and insert them between the "for row in cursor" and "print ..." rows of your working script.&lt;/LI&gt;&lt;LI&gt;You will need to change &lt;STRONG&gt;"SFR", 125000&lt;/STRONG&gt; of the copied line 2 of the tax script to use row[1] and row[2].&lt;/LI&gt;&lt;LI&gt;Modify the print statement to: print "{0}: {1}".format(row[0], mytax)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then test your script and let us know how it is working. &amp;nbsp; If you have problems, post your script, and comments will be provided.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:27:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350161#M904</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T16:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: python functions and classes</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350162#M905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you!! it was really big help, it works fine&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Mar 2020 21:23:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350162#M905</guid>
      <dc:creator>CNRFGN</dc:creator>
      <dc:date>2020-03-21T21:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: python functions and classes</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350163#M906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If someone's response answered your question, mark it correct to give credit and close out the question.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Mar 2020 22:40:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/python-functions-and-classes/m-p/350163#M906</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-03-21T22:40:20Z</dc:date>
    </item>
  </channel>
</rss>

