Fixed issue in define.gridcells() on Boundaries

The previous commit didn't completley fix the issue with the grid
cells on the boundaries. I solved the problem by using a for loop to
correctly compute the center of the grid cells.