In the absence of consistent meteorological data on Mars, the morphology of dunes can be employed to study its atmosphere. Specifically, barchan dunes, which form under approximately unimodal winds, are reliable proxies for the dominant wind direction. Here, we characterize near-surface winds on Mars from the morphology of >106 barchans mapped globally on the planet by a convolutional neural network. Barchan migration is predominantly aligned with the global circulation: northerly at mid-latitudes and cyclonic near the north pole, with the addition of an anti-cyclonic north-polar component that likely originates from winds emerging from the ice cap. Locally, migration directions deviate from regional trends in areas with high topographic roughness. Notably, obstacles <100 km such as impact craters are efficient at deflecting surface winds. Our database, which provides insights into planetary-scale aeolian processes on modern-day Mars, can be used to constrain global circulation models to assist with predictions for future missions.