By atomistic modeling of moiré patterns of graphene on a substrate with a small lattice mismatch, we find qualitatively different strain distributions for small and large misorientation angles, corresponding to the commensurate-incommensurate transition recently observed in graphene on hexagonal BN. We find that the ratio of C-N and C-B interactions is the main parameter determining the different bond lengths in the center and edges of the moiré pattern. Agreement with experimental data is obtained only by assuming that the C-B interactions are at least twice weaker than the C-N interactions. The correspondence between the strain distribution in the nanoscale moiré pattern and the potential energy surface at the atomic scale found in our calculations makes the moiré pattern a tool to study details of dispersive forces in van der Waals heterostructures.