Returns a string representation of the raster in GRASS ASCII raster format.

def getAsGrassAsciiRaster(self, tableName, rasterId=1, rasterIdFieldName='id', rasterFieldName='raster', newSRID=None):
        """
        Returns a string representation of the raster in GRASS ASCII raster format.
        """
        # Get raster in ArcInfo Grid format
        arcInfoGrid = self.getAsGdalRaster(rasterFieldName, tableName, rasterIdFieldName, rasterId, 'AAIGrid', newSRID).splitlines()

        ## Convert arcInfoGrid to GRASS ASCII format ##
        # Get values from header which look something this:
        # ncols        67
        # nrows        55
        # xllcorner    425802.32143212341
        # yllcorner    44091450.41551345213
        # cellsize     90.0000000
        # ...
        nCols = int(arcInfoGrid[0].split()[1])
        nRows = int(arcInfoGrid[1].split()[1])
        xLLCorner = float(arcInfoGrid[2].split()[1])
        yLLCorner = float(arcInfoGrid[3].split()[1])
        cellSize = float(arcInfoGrid[4].split()[1])

        # Remove old headers
        for i in range(0, 5):
            arcInfoGrid.pop(0)

        # Check for NODATA_value row and remove if it is there
        if 'NODATA_value' in arcInfoGrid[0]:
            arcInfoGrid.pop(0)

        ## Calculate values for GRASS ASCII headers ##
        # These should look like this:
        # north: 4501028.972140
        # south: 4494548.972140
        # east: 460348.288604
        # west: 454318.288604
        # rows: 72
        # cols: 67
        # ...

        # xLLCorner and yLLCorner represent the coordinates for the Lower Left corner of the raster
        north = yLLCorner + (cellSize * nRows)
        south = yLLCorner
        east = xLLCorner + (cellSize * nCols)
        west = xLLCorner

        # Create header Lines (the first shall be last and the last shall be first)
        grassHeader = ['cols: %s' % nCols,
                       'rows: %s' % nRows,
                       'west: %s' % west,
                       'east: %s' % east,
                       'south: %s' % south,
                       'north: %s' % north]

        # Insert grass headers into the grid
        for header in grassHeader:
            arcInfoGrid.insert(0, header)

        # Create string
        arcInfoGridString = '\n'.join(arcInfoGrid)
        return arcInfoGridString