Wepresent a method to calculate the Landau levels and the corresponding edge states of two dimensional (2D) crystals using as a starting point their electronic structure as obtained from standard density functional theory (DFT). The DFT Hamiltonian is represented in the basis of maximally localized Wannier functions. This defines a tight-binding Hamiltonian for the bulk that can be used to describe other structures, such as ribbons, provided that atomic scale details of the edges are ignored. The effect of the orbital magnetic field is described using the Peierls substitution in the hopping matrix elements. Implementing this approach in a ribbon geometry, we obtain both the Landau levels and the dispersive edge states for a series of 2D crystals, including graphene, Boron Nitride, MoS2, Black Phosphorous, Indium Selenide and MoO3. Our procedure can readily be used in any other 2D crystal, and provides an alternative to effective mass descriptions.