Grating is a widely-used standard to calibrate the horizontal plane of almost all kinds of microscopes. A grating standard consisting of 1D grating and 2D grating was designed and fabricated by Shanghai Institute of Measurement and Testing Technology (SIMT). In this paper, a metrological large-range nano measuring machine integrated with atomic force microscope (AFM) and laser focus sensor (LFS) is used to calibrate this standard. In order to guarantee the measurement accuracy, cosine error, a significant error source which is caused by deviation angle between the scan direction and the perpendicular direction of the grating line, is analysed. Therefore, the scan direction should be determined accurately. For 1D grating, the scan direction is determined by two scanning profiles with deflection angle. Different beginning directions and deflection angles are analyzed to find the best beginning direction and deflection angle for fast and accurate scan direction determination. For 2D grating, the application of the same scan direction determination procedure is extended by using beginning direction and deflection angle which is opposite for 1D grating. Mean pitch is calculated through another profile which is scanned along the calculated scanning direction. Data from different probes are evaluated and the results demonstrate the method well.