method to know convert xy to grid index