<?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: get ASCII row and column info in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424924#M33373</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The results were slightly off and it took me a bit to figure out why. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;xllcenter &amp;amp; yllcenter provide the coordinates at the center of the most lower left ASC cell. In order to find the coordinates at the lower left corner of the lower left cell, you need to subtract half of the cell size from both coordinates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, with a cell size of 15 meters&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;xllCenter = xllCenter - 7.5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;yllCenter = yllCenter - 7.5&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Feb 2013 20:57:32 GMT</pubDate>
    <dc:creator>DavidReeves</dc:creator>
    <dc:date>2013-02-13T20:57:32Z</dc:date>
    <item>
      <title>get ASCII row and column info</title>
      <link>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424919#M33368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a point shapefile and an ascii grid. When you view an ascii grid in a text editor the header tells you the xy coordinates of the center then the values are all displayed in neat rows and columns. What I am trying to find out is what column and row those points fall in. When both are added to ArcMap I can find out the value of the cell, but I want the column and row number. Anyone have any clue how this can be accomplished?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;ncols&amp;nbsp; 1926 nrows&amp;nbsp; 2752 xllcenter 533993.691804 yllcenter 3247644.275250 cellsize 15.000000 NODATA_value -9999 -9999&amp;nbsp; -9999&amp;nbsp; -9999&amp;nbsp; -9999&amp;nbsp; -9999&amp;nbsp; ... -9999&amp;nbsp; -9999&amp;nbsp; -9999&amp;nbsp; 0.0&amp;nbsp; 0.0&amp;nbsp; ... -9999&amp;nbsp; -9999&amp;nbsp; -9999&amp;nbsp; 0.0&amp;nbsp; 0.0&amp;nbsp; ... -9999&amp;nbsp; -9999&amp;nbsp; -9999&amp;nbsp; 123.4&amp;nbsp; 123.4&amp;nbsp; ... ...&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2013 19:50:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424919#M33368</guid>
      <dc:creator>DavidReeves</dc:creator>
      <dc:date>2013-02-12T19:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: get ASCII row and column info</title>
      <link>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424920#M33369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi David,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if you´re looking for the row/column of a single point it should be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Column = (CurrentXcoordinate - XLLcenter) / Cellsize&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Row = (nrows -1) - (CurrentYcoordinate - YLLcenter) / Cellsize&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2013 06:35:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424920#M33369</guid>
      <dc:creator>RaphaelR</dc:creator>
      <dc:date>2013-02-13T06:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: get ASCII row and column info</title>
      <link>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424921#M33370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's exactly what I ended up doing. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I just need to figure out what to do with interpreting the decimal result.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ex. is 37.604 in the 37th row or the 38th row? I'm thinking 38th. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;file = open(r"C:\WorkSpace\Grid.asc")&amp;nbsp; nCols = file.readline() nRows = file.readline() xllCenter = file.readline() yllCenter = file.readline() cellSize = file.readline()&amp;nbsp; file.close()&amp;nbsp; nCols = re.sub('ncols', '', re.sub('\s','',nCols)) nRows = re.sub('nrows', '', re.sub('\s','',nRows)) xllCenter = float(re.sub('xllcenter', '', re.sub('\s','',xllCenter))) yllCenter = float(re.sub('yllcenter', '', re.sub('\s','',yllCenter))) cellSize = float(re.sub('cellsize', '', re.sub('\s','',cellSize)))&amp;nbsp; # subtract half the cell size to get the coordinates at the lower left corner of the cell, not the exact center xllCenterAdjust = xllCenter - 7.5 yllCenterAdjust = yllCenter - 7.5&amp;nbsp; pointX = 534557.7644 pointY = 3248152.003&amp;nbsp; xColumn = ((pointX - xllCenterAdjust)/cellSize) yColumn = ((pointY - yllCenterAdjust)/cellSize)&amp;nbsp; print xColumn print yColumn&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2013 12:58:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424921#M33370</guid>
      <dc:creator>DavidReeves</dc:creator>
      <dc:date>2013-02-13T12:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: get ASCII row and column info</title>
      <link>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424922#M33371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;Column = (CurrentXcoordinate - XLLcenter) / Cellsize&lt;BR /&gt;Row = (nrows -1) - (CurrentYcoordinate - YLLcenter) / Cellsize&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Why did you include "(nrows-1) -" to calculate the row?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I used the script in my previous post to find the row and column. To check my work, I changed the value in the resulting ASCII row &amp;amp; column to something unique and set ArcMap to display that value with a unique color. I expected the point to fall in that cell, but it was way off (more than "nrows-1"). What could be causing this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2013 17:58:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424922#M33371</guid>
      <dc:creator>DavidReeves</dc:creator>
      <dc:date>2013-02-13T17:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: get ASCII row and column info</title>
      <link>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424923#M33372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Why did you include "(nrows-1) -" to calculate the row?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Row values, by convention, start at&amp;nbsp; the top with row zero located at the highest y values. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the old days of image processing, the terminology was line and sample. I believe this convention goes back to TV and also when we often looked at raster images printed out using coded values on line printers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Those were the days.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2013 18:40:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424923#M33372</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-02-13T18:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: get ASCII row and column info</title>
      <link>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424924#M33373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The results were slightly off and it took me a bit to figure out why. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;xllcenter &amp;amp; yllcenter provide the coordinates at the center of the most lower left ASC cell. In order to find the coordinates at the lower left corner of the lower left cell, you need to subtract half of the cell size from both coordinates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, with a cell size of 15 meters&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;xllCenter = xllCenter - 7.5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;yllCenter = yllCenter - 7.5&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2013 20:57:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-ascii-row-and-column-info/m-p/424924#M33373</guid>
      <dc:creator>DavidReeves</dc:creator>
      <dc:date>2013-02-13T20:57:32Z</dc:date>
    </item>
  </channel>
</rss>

