Though a global assessment of rooftop solar photovoltaic (RTSPV) technology's potential and the cost is needed to estimate its impact, existing methods demand extensive data processing. Here, the authors report a machine learning method to realize a high-resolution global assessment of RTSPV potential.Rooftop solar photovoltaics currently account for 40% of the global solar photovoltaics installed capacity and one-fourth of the total renewable capacity additions in 2018. Yet, only limited information is available on its global potential and associated costs at a high spatiotemporal resolution. Here, we present a high-resolution global assessment of rooftop solar photovoltaics potential using big data, machine learning and geospatial analysis. We analyse 130 million km(2) of global land surface area to demarcate 0.2 million km(2) of rooftop area, which together represent 27 PWh yr(-1) of electricity generation potential for costs between 40-280 $ MWh(-1). Out of this, 10 PWh yr(-1) can be realised below 100 $ MWh(-1). The global potential is predominantly spread between Asia (47%), North America (20%) and Europe (13%). The cost of attaining the potential is lowest in India (66 $ MWh(-1)) and China (68 $ MWh(-1)), with USA (238 $ MWh(-1)) and UK (251 $ MWh(-1)) representing some of the costliest countries.