<?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 Get raster cell XY and VALUE? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/get-raster-cell-xy-and-value/m-p/470216#M36708</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Anyone out there know how to access a raster cell's center XY and VALUE directly?&amp;nbsp; I could arcpy.RasterToPoint and then get it from there, but that seems like an extra step.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!:D&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Jun 2012 14:08:45 GMT</pubDate>
    <dc:creator>KevinBell</dc:creator>
    <dc:date>2012-06-15T14:08:45Z</dc:date>
    <item>
      <title>Get raster cell XY and VALUE?</title>
      <link>https://community.esri.com/t5/python-questions/get-raster-cell-xy-and-value/m-p/470216#M36708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Anyone out there know how to access a raster cell's center XY and VALUE directly?&amp;nbsp; I could arcpy.RasterToPoint and then get it from there, but that seems like an extra step.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!:D&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2012 14:08:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-raster-cell-xy-and-value/m-p/470216#M36708</guid>
      <dc:creator>KevinBell</dc:creator>
      <dc:date>2012-06-15T14:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get raster cell XY and VALUE?</title>
      <link>https://community.esri.com/t5/python-questions/get-raster-cell-xy-and-value/m-p/470217#M36709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, am I going nuts, or is it just Friday? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to build a dict of raster values to later build into a point feature class, and I'm getting a syntax error in the += down where I'm filling my dictionary.&amp;nbsp; I don't see the problem.&amp;nbsp; :confused:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The dict looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(x,y): value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll append other values to the xy later&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import pprint

theRaster = r'C:\gis\solarTESTING\default.gdb\d1'
ras = arcpy.Raster(theRaster)
ar = arcpy.RasterToNumPyArray(theRaster)

xmin = ras.extent.XMin 
ymax = ras.extent.YMax

yheight, xwidth = ar.shape

d={}

for i in xrange(xwidth):
 d[xmin += i, ymax] = ar[0]&lt;I&gt;
 
for j in xrange(yheight):
 d[xmin, ymax -= j] = ar&lt;J&gt;[0]

pprint.pprint(d) &lt;/J&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:49:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-raster-cell-xy-and-value/m-p/470217#M36709</guid>
      <dc:creator>KevinBell</dc:creator>
      <dc:date>2021-12-11T20:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get raster cell XY and VALUE?</title>
      <link>https://community.esri.com/t5/python-questions/get-raster-cell-xy-and-value/m-p/470218#M36710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't think you can re-assign a variable while you're using it as an index. You will probably have to break it into 2 lines&lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;for i in xrange(xwidth): &amp;nbsp;&amp;nbsp;&amp;nbsp; xmin += i &amp;nbsp;&amp;nbsp;&amp;nbsp; d[xmin, ymax] = ar[0]&lt;I&gt;&amp;nbsp;&amp;nbsp; for j in xrange(yheight): &amp;nbsp;&amp;nbsp;&amp;nbsp; ymax -= j &amp;nbsp;&amp;nbsp;&amp;nbsp; d[xmin, ymax] = ar&lt;J&gt;[0]&lt;/J&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's what I tried in the interactive window&lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt;&amp;gt;&amp;gt; a=[1,2,3] &amp;gt;&amp;gt;&amp;gt; b=1 &amp;gt;&amp;gt;&amp;gt; a[b+=1] Traceback (&amp;nbsp; File "&amp;lt;interactive input&amp;gt;", line 1 &amp;nbsp;&amp;nbsp;&amp;nbsp; a[b+=1] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^ SyntaxError: invalid syntax&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2012 16:44:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-raster-cell-xy-and-value/m-p/470218#M36710</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-06-15T16:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get raster cell XY and VALUE?</title>
      <link>https://community.esri.com/t5/python-questions/get-raster-cell-xy-and-value/m-p/470219#M36711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That did it!&amp;nbsp; Thanks!&amp;nbsp; I was going batty!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NOTE that code doesn't do what i want just yet, but it is ok as far as i've gotten on it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2012 16:50:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-raster-cell-xy-and-value/m-p/470219#M36711</guid>
      <dc:creator>KevinBell</dc:creator>
      <dc:date>2012-06-15T16:50:03Z</dc:date>
    </item>
  </channel>
</rss>

