Forests play an important role in maintaining rainfall patterns worldwide by recycling water back to the atmosphere through evapotranspiration. We present a novel spatiotemporal data-driven model and assessment of the impacts of various deforestation scenarios on rainfall patterns in sub-Saharan Africa, where rainfed agriculture is the main source of income and provides food for a large part of the population. Our model is based on the convolutional long short term memory neural network and uses a combination of climate and vegetation time-series data to predict rainfall and to perform simulation experiments. Our results show that complete deforestation (i.e. conversion of all humid forests to short grasslands) would greatly reduce rainfall magnitude in the deforested areas. Above the equator, the large majority of areas not currently forested would also receive less rainfall. However, complete deforestation would slightly increase rainfall in some parts of Southern Africa and decrease it in other parts. The impacts of partial deforestation also differ across Africa. In West Africa, even moderate tree cover loss (i.e. 30%) reduces rainfall magnitude whereas in Central and Southern Africa, a threshold of 70% tree cover loss is required to reduce rainfall magnitude. Deforestation of remaining humid rainforest areas is thus likely to dramatically affect rainfed agriculture across the continent, in particular in the maize-based cropping systems north of the equator.