My question is related to Converting SQL Server Rasters to ASCII Grid?

I would like to transform the data in the database into Esri grid format.

I would like to write the program/script myself and wonder how these values are computed:

xllcorner, yllcorner, cellsize

I know that my squares are 25km^2. The wiki site mentions easting and northings. Should I just transform the lower left latitude/longitude values into easting and northings and use 25 for cellsize?

  • Welcome to GIS.se csetzkorn. :) I reformatted a little to improve readability. FYI, internal links to questions are automatically expanded to their title, so you can just paste http:... and carry on. Oct 23, 2011 at 4:36

1 Answer 1


Your data will not be a regular square grid both in lat,lon and in projected coordinates: it's either in one or the other. Since you say the cells are 25 square kilometers, it sounds like the grid makes sense only in projected coordinates.

Note that square kilometers measure area, not length. Either your cells are 25 kilometers (not squared) on a side (which would give them areas of 625 square kilometers and lengths of 25,000 meters), or else they are sqrt(25,000,000 square meters) = 5000 meters on a side. The cellsize must be the common side length of each square cell (in meters, not kilometers), not the cell area.

There is another subtlety: the lower left corner is usually not the coordinates of the lower left point in the grid; it's the coordinates of the lower left corner of the cell in which the lower left grid point is the center. Thus, to compute (xllcorner, yllcorner), you have to subtract half the cellsize from each of the coordinates of the lower left grid point.

A reliable way to create grid header files is to create a simple grid (such as a constant grid or random grid) having exactly the desired origin, extent, and cellsize. Export that grid in ASCII format. Throw its data away--keep the header file: it contains exactly what you need, formatted in a way acceptable to your software. This will reveal the relationships between the contents of the header and the values you specified when making the grid.

  • Actually my grid is as follows. Latitude is in the range [-90 ... 90] and longitude [-180 ... 180]. A square’s/cell’s size is 2.5 degrees – I have been told that corresponds to 25 square kilometres.
    – cs0815
    Oct 24, 2011 at 12:15
  • 1
    @cs OK, then use 2.5 for the cellsize and (-180,-90) for the origin. Incidentally, a square degree covers approximately 12000*cos(latitude) square kilometers. That's 8700 square kilometers at a 45 degree latitude, for instance (more for latitudes nearer the equator, less for latitudes nearer the pole). Your informant must live on a small planetoid or asteroid :-).
    – whuber
    Oct 24, 2011 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.