<?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: How to obtain number of cells in neighborhood from NbrWeight neighborhood object? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464640#M36393</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amelie,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Irregular neighborhoods could be implemented better in arcpy. Here's more fun I've had with them:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/message/402363"&gt;Working with kernel files in arcpy: NbrIrregular bug&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is one massive kernel file!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Oct 2015 01:43:26 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2015-10-16T01:43:26Z</dc:date>
    <item>
      <title>How to obtain number of cells in neighborhood from NbrWeight neighborhood object?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464636#M36389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd like to get the first two numbers in the .txt file that is loaded as by NbrWeight (neighborhood object weights) for the focal statistics tool.&lt;/P&gt;&lt;P&gt;I want to use them to calculate the area of the rectangle that is the neighborhood.&lt;/P&gt;&lt;P&gt;How do I easily access the values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I have so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;inWeightFile = arcpy.GetParameterAsText(5)&lt;/P&gt;&lt;P&gt;if inWeightFile == '#' or not inWeightFile:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inWeightFile = "C:\\temp\\PPR\\Test\\bee_kernel_2_5km.txt" # provide a default value if unspecified&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Create the Neighborhood Object for the buffer&lt;/P&gt;&lt;P&gt;myNbrWeight = arcpy.sa.NbrWeight(inWeightFile)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Get number of cells in the buffer&lt;/P&gt;&lt;P&gt;NbrCellsBuffer = 65 * 65 # XXX need to fix this. Should come from first two numbers in inWeightFile &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Focal Statistics - within buffer calculate sum of f_rc1_H1 with exponential decay function and divide by number of cells in buffer&lt;/P&gt;&lt;P&gt;arcpy.AddMessage("Calculate proportional cover of high floral quality classes within buffer for first floral season")&lt;/P&gt;&lt;P&gt;f_rc_f_H1 = (arcpy.sa.FocalStatistics(f_rc1_H1, myNbrWeight, "SUM", "NODATA") * outConstRaster) / NbrCellsBuffer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Amelie&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Oct 2015 17:06:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464636#M36389</guid>
      <dc:creator>AmelieDavis</dc:creator>
      <dc:date>2015-10-15T17:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain number of cells in neighborhood from NbrWeight neighborhood object?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464637#M36390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;showing the text file would be useful&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Oct 2015 20:06:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464637#M36390</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-10-15T20:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain number of cells in neighborhood from NbrWeight neighborhood object?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464638#M36391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes, sorry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The text file is just the kernel they talked about here&amp;nbsp; &lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005m0000006q000000" title="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005m0000006q000000"&gt;ArcGIS Desktop&lt;/A&gt; saved as a .txt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm attaching my kernel (it's a bit more complicated than the examples provided in the help).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Amelie&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Oct 2015 21:18:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464638#M36391</guid>
      <dc:creator>AmelieDavis</dc:creator>
      <dc:date>2015-10-15T21:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain number of cells in neighborhood from NbrWeight neighborhood object?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464639#M36392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ncols, nrows = [int(s) for s in open(inWeightFile).readlines()[0].strip().split()]
NbrCellsBuffer = ncols * nrows&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above opens the file and grabs the first line, strips off the newline ('\n') character and splits it into a list of two strings at the space then uses python list comprehension to convert the strings to integer values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464639#M36392</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-11T20:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain number of cells in neighborhood from NbrWeight neighborhood object?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464640#M36393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amelie,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Irregular neighborhoods could be implemented better in arcpy. Here's more fun I've had with them:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/message/402363"&gt;Working with kernel files in arcpy: NbrIrregular bug&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is one massive kernel file!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Oct 2015 01:43:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-obtain-number-of-cells-in-neighborhood-from/m-p/464640#M36393</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2015-10-16T01:43:26Z</dc:date>
    </item>
  </channel>
</rss>

