The nature and origin of the asteroids orbiting in near-Earth space, including those on a potentially hazardous trajectory, is of both scientific interest and practical importance. We aim here at determining the taxonomy of a large sample of near-Earth (NEA) and Mars-crosser (MC) asteroids and analyze the distribution of these classes with orbit. We use this distribution to identify their source regions and to study the strength of planetary encounters to refresh asteroid surfaces. We measure the photometry of these asteroids over four filters at visible wavelengths on images taken by the SDSS. These colors are used to classify the asteroids into a taxonomy consistent with the widely used Bus-DeMeo taxonomy based on spectroscopy. We report here on the taxonomic classification of 206 NEAs and 776 MCs determined from SDSS photometry, representing an increase of 40% and 663% of known taxonomy classifications in these populations. Using the source region mapper by Greenstreet et al. (2012), we compare the taxonomic distribution among NEAs and main-belt asteroids of similar diameters. Both distributions agree at the few percent level for the inner part of the Main Belt and we confirm this region as a main source of near-Earth objects. The effect of planetary encounters on asteroid surfaces are also studied by developing a simple model of forces acting on a surface grain during planetary encounter, which provides the minimum distance at which a close approach should occur to trigger resurfacing events. By integrating numerically the orbit of the 519 S-type and 46 Q-type asteroids back in time and monitoring their encounter distance with planets, we seek to understand the conditions for resurfacing events. The population of Q-type is found to present statistically more encounters with Venus and the Earth than S-types, although both types present the same amount of encounters with Mars.