Precision agriculture (PA) and yield gap (Yg) analysis are promising strategies to achieve the desired sustainable intensification of agricultural production systems. Current crop Yg approaches do not consider the internal field yield variability caused by soil properties. Topographic and edaphic characteristics causing consistent high and low yield patterns in time and space can be interpreted as an ecological niche and used as proxies for potential yield (Yp) and Yg. Ecological niche models (ENMs) are statistical models originally developed to forecast a species’ niche. However, its application to analyse crop yield spatio-temporal variability has never been made. This study aimed to fill this void by developing a novel approach: i) to quantify the magnitude and spatio-temporal distribution of Yp and Yg, ii) to identify the main factors that cause the Yg, and iii) to provide statistical and agronomical interpretation of the data to reduce the Yg. We performed this work using high-resolution maize yield maps from three seasons, with an ancillary dataset composed of soil electrical conductivity, soil properties and digital elevation models provided by “Quinta da Cholda”, Portugal. The yield maps were averaged, resulting in a standardised multiyear yield map. The 90th and 10th yield percentiles were interpreted as proxies for Yp and Yg, and analysed by an ENM machine learning algorithm – maximum entropy (MaxEnt). The average Yg and Yp were quantified as 1.5 and 19.1 ton/ha. Yp was characterised by having silty, richer soils and lower elevations, with several nutritional factors above the critical limits to maintain higher yields. Yg had loam soils coupled with higher relative elevations and lower nutrition content. This innovative modelling approach can efficiently manage high-dimensional spatio-temporal data to support advanced PA solutions, allowing detailed support for narrowing the Yg.