title: Reading .grd file in Python
body: <p>Some files in <code>ESRI grid format</code>(suffixed in <strong>.grd</strong>) is a geospatial dataset with left low X corner, left low Y corner and value.   </p>
  
  <p>The file look like this(using vim to read it):      </p>
  
  <pre><code>   1 ncols 2880
     2 nrows 1440
     3 xllcorner -180.0
     4 yllcorner  -90.0
     5 cellsize 0.125
     6 nodata_value -999
     7 version 2.0
  
     8  -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 ...
  </code></pre>
  
  <p>For now, I manipulate these files with a manual pre-process approach.  </p>
  
  <ol>
  <li>Delete the first 7 rows</li>
  <li>Save the .grd files into <code>.txt</code>file. </li>
  <li>Read the <code>.txt</code>file using numpy into a numpy array representing the spatial attribute</li>
  <li>Combined with the first 7 rows, generate the Lon and Lat array corresponding to the attribute array(For my cas (1440 x 2880))  </li>
  </ol>
  
  <p>Now, I want to realize reading the file directly:  </p>
  
  <ul>
  <li>Value   -> Begin from the 8th line</li>
  <li>Longitude -> generater by ncols, cellsize &amp; xllcorner     </li>
  <li>Longitude -> generater by nrows, cellsize &amp; yllcorner</li>
  </ul>
  
  <h3>My attempt</h3>
  
  <pre><code> ## Read the first seven lines using LineCache
   ncols = linecache.getline("grd file", 1)
   ......
   ## Read the array using np.loadtxt()
   myArray  = np.loadtxt("grd file", skiprows=7) 
  </code></pre>