Climate and landscape changes as driving forces for future range shift in southern populations of the European badger

Human-Induced Rapid Environmental Change (HIREC), particularly climate change and habitat conversion, affects species distributions worldwide. Here, we aimed to (i) assess the factors that determine range patterns of European badger (Meles meles) at the southwestern edge of their distribution and (ii) forecast the possible impacts of future climate and landcover changes on those patterns. We surveyed 272 cells of 5 × 5 km, to assess badger presence and confirmed its occurrence in 95 cells (35%). Our models estimate that badger’s presence is promoted by the occurrence of herbaceous fields and shrublands (5%–10%), and low proportions of Eucalyptus plantations (<~15%). Regions with >50% of podzols and eruptive rocks, higher sheep/goat density (>4 ind/km2), an absence of cattle, intermediate precipitation regimes (800–1000 mm/year) and mild mean temperatures (15–16 °C) are also more likely to host badgers. We predict a decrease in favourability of southern areas for hosting badgers under forecasted climate and landcover change scenarios, which may lead to a northwards retraction of the species southern distribution limit, but the overall landscape favourability is predicted to slightly increase. The forecasted retraction may affect community functional integrity, as its role in southern ecological networks will be vacant.

www.nature.com/scientificreports www.nature.com/scientificreports/ between the H5 model and the other best models produced for hypotheses H1-H4 are not high, but they indicate that the hypotheses are not completely mutually exclusive as H1-H4 included variables also present in the H5 best model. This H5 model highlighted that the percentages of podzol soils and herbaceous landcover were the most influential variables (8.53% and 8.08%, respectively; Fig. 2), with a difference of importance between both of only 5.28% (i.e. a difference of 0.45% represents 5.28% of 8.53%; Fig. 2). The difference between the relative importance of these two variables and other variables is not high, but the difference in percentage of importance reaches ~9% between the second and third most important variables (7.4%, 0.70% difference relative to % importance of podzols; Fig. 2). Furthermore, although the RAC autocovariate has a high relative importance (45.06%), the RAC-BRT model still allows for the environmental and anthropogenic disturbance variables to contribute to deviance reduction of the model while removing the model residuals responsible for spatial autocorrelation 37 . The RAC-BRT model residuals confirm this result, as no significant spatial autocorrelation was detected in the model residuals (Moran I = −0.017, p = 0.067).
The variables included in the best model showed distinct patterns regarding their relationships with badger presence (Fig. 2). Badgers have a higher probability of being present: (1) in areas with herbaceous fields and shrublands, but covering less than 20% and 15% of the landscape, respectively (ideally between 5 and 10% for both landcover types), and where Eucalyptus plantations represent <15% of the landscape; (2) in regions with more than 50% of podzols in the soil structure and at least 50% of eruptive rocks; (3) where sheep/goat density is above 4 ind/km 2 , but cattle are absent or exist in low densities (<0.5 ind/km 2 ); and (4) in areas subjected to annual precipitation of between 800 and 1000 mm, and mild annual mean temperatures of between 15-16 °C (Fig. 2). Badgers avoid areas almost without goats and sheep (<2 ind/km 2 ) (Fig. 2). www.nature.com/scientificreports www.nature.com/scientificreports/ Based on our hybrid model we estimated the probability of badger presence to be high in central Portugal, particularly in the Tejo River basin (a floodplain influenced by this major river) and near the central coast of the country (Fig. 3a). The favourability map confirms this pattern, but also highlighted the importance of many inland regions near the Spanish border (Fig. 3b).
The independent badger presence data (Fig. S2, Supplementary Material) confirmed species presence in 68 of our 5 × 5 km cells. Of those, 44% (N = 30) were identified in our favourability map as moderately or very suitable to host badgers (i.e. F > 0.50). Furthermore, this percentage increased if we considered cells whose favourability almost reached the threshold of F > 0.50; 11 cells had F values in the range 0.45-0.50 (which when included enhanced detection of favourable areas to 60%). The percentage of cells containing independent badger presence data, which were identified by the best model as moderately or very suitable to host badgers (F > 0. 45), was similar between areas where monitoring was more representative (Central north; 60.78% of the test cells; Fig. 1) and where sampling was less intensive (Central south; 58.82% of the test cells; Fig. 1).
We produced favourability maps of badger presence in Portugal for 2040 based on four land-use change scenarios described by Stürck and colleagues 38 and an IPCC climate prediction (Scenario A1B 17 ) (Fig. 4). All scenarios presented a similar output. By 2040, badger landscape favourability seems to increase in the country's eastern and northeastern regions, but decreases in the North-west. Furthermore, the southern edge of the species range seems to decrease in adequacy for badgers, with a decrease of 50% in the number of cells with favourability >0.75 in area south of the Tejo River (from 35 -current situation -to 16, 15, 17 and 18 for the Libertarian Europe -A1_2040, Eurosceptic Europe -A2_2040, Social Democracy Europe -B1_2040 and European Localism -B2_2040 scenarios, respectively). The central region, which formed a core area of the most adequate territory for the species, loses some regions characterized as highly favourable (red cells), and coverage of cells representing the least suitable areas (lighter orange cells) expands in southern Portugal (evidenced by a slight reduction in this area average favourability, from 0.484 -current situation -to 0.474, 0.473, 0.470 and 0.472 for the A1_2040, A2_2040, B1_2040 and B2_2040 scenarios, respectively). Comparing the overall favourability of the country according to the four forecasted scenarios, we observed a non-significant increase (mean increase: 2.75%;

Discussion
The estimated current distribution (i.e. range predictability and favourability) of the European badger at the limit of its southwestern range (Portugal) is widespread but patchy, and is mostly determined by a combination of landcover, environmental and anthropogenic disturbance drivers. These drivers are affected by different aspects of HIREC acting synergistically to shape the species' distribution pattern. Badgers seem to be sensitive to changes in native (herbaceous fields and shrublands) and exotic (Eucalyptus plantations) vegetation cover, but also to soil and rock composition (preference for podzols and eruptive rocks), the intensity of pastoral activities (i.e. density of sheep/goats and cattle), and climatic conditions (i.e. temperature and precipitation). This combination of multiple drivers supports our fifth hypothesis (H5).
Badger distribution. We found that central Portugal is regionally the most favourable area for badgers, with two core critical areas, broadly corresponding to the Tejo River basin and the western coastal plains. Part of the eastern region bordering Spain also has characteristics that favour badger presence (Fig. 3b). This pattern may represent the historical distribution of the species at the southwestern edge of its range. In a study based on badger-associated toponomy (i.e. regional designations or place-names, indicating species presence in the past), Rosalino and colleagues 39 identified place-names associated with badgers ranging from the south coastal region of Algarve to the northern borders of Portugal, and from the western coast to the eastern regions, near the Spanish border, suggesting that the species was also historically widespread. The patchy favourability for badgers in Portugal reveals that adequate areas for badger survival are discontinuously distributed (Fig. 3b).

Landscape drivers of badger distribution. Two major habitat factors shape badger distribution in
Portugal: landcover and soil/rock structure. Our data indicates that areas showing some heterogeneity are preferred (as also found by Piza-Roca and colleagues 40 ). Herbaceous fields and shrublands presented a positive influence on badger presence, up to a threshold of 20% and 15% coverage of the landscape, respectively, with an optimal coverage of between 5 and 10%. Heterogeneous environments can have deleterious effects on some populations, leading to decline or even extinction (e.g. prey species 41 ), whereas others can take advantage of the multiple resources they provide. Badgers can benefit from heterogeneous habitats, using the combined resources (food and refuge) provided by such temporal and spatial heterogeneity, especially southern populations (e.g. in semi-arid environments 30,42 ; in Mediterranean oak forests 43 ). Herbaceous fields can provide easy access to food resources, such as insects (naturally available or derived from use of these patches by domestic ungulates, e.g. dung beetles 44 ), earthworms (which are mainly concentrated in herbaceous areas 45,46 ), or rodents and rabbits 47,48 . However, badgers are more exposed to humans in such open areas, which are characterized by having less than 20% of cover. Shrublands provide protective cover 43 , but since badgers can be considered more efficient food gatherers than active predators (but see 47 ), higher shrub cover makes prey detection harder. Furthermore, high shrub cover is often associated with low abundance of some badger prey, such as earthworms 49 and rabbits 50 , which may contribute to avoidance of those areas. Therefore, a compromise between protective cover and foraging habitat may have resulted in the selection of areas with low shrubland cover by badgers in Portugal.
Eucalyptus plantations cover ca. 9% of the Portuguese territory and represent 26% of all Portuguese forested areas 51 . They have been shown to have a negative effect on southern badger populations 35,43,52 . The effects of Eucalyptus plantations on wildlife are often associated with food scarcity and high disturbance 35 . However, these habitats can harbour abundant populations of prey if understory shrubs are managed properly (e.g. 53,54 ) to provide efficient protective cover, especially in the absence of native forests 55 . Furthermore, their degrees of disturbance vary with harvesting phase (i.e. higher in pre-harvesting phases 56 ) and plantation extent 35 . Our results support a positive effect of scarce Eucalyptus habitats (<~15% of the landscape), which likely deliver a combination of food resource availability, protective cover, and reduced anthropogenic disturbance.
We found that not only above-ground habitat characteristics drive badger presence in Portugal, since soil and rock types also emerged as being influential in our analysis. Podzols are often formed under forest ecosystems and are usually considered poor soils for agriculture as they possess low levels of moisture and lack many nutrients 57,58 . Although use of agricultural landscapes by badgers may be a mechanism to facilitate access to food (e.g., 30,43 ), agricultural fields suffer frequent soil mobilization to prepare the land for planting or when harvesting production and they are subjected to high human disturbance. This high disturbance level likely limits badger presence, with this latter being more common in areas not suitable for agriculture and where soils are covered by forests, such as those dominated by podzols (>50% of podzols in the soil structure, as detected by our analysis). Often these more "natural" habitat patches are composed of a mixture of tree cover in different successional stages (from forest with sparse understory or shrublands with sparse tree cover to more closed environments), which may provide the necessary cover/protection badgers need. This heterogeneous structure may not have been completely captured by our landcover classes (often composed of monotypic landcover types), preventing a more accurate assessment of their importance in our models. Setts are essential structures for badgers and their stability is a determining factor for population survival 59 . Eruptive rocks can provide such stability, although they also present badgers with a huge challenge when digging a sett. Under such conditions, geological discontinuities may facilitate sett-building 31 . However, no data was available at a national scale to allow us to test this hypothesis.
Apart from Eucalyptus plantations, other anthropogenic factors contribute to shaping badger distribution in Portugal. Our results suggest that badgers avoid areas with higher cattle density (>0.5 ind/km 2 ), but high densities of sheep/goats (>4 ind/km 2 ) promote their presence. Although there is some previous data showing that badgers use agroforestry systems devoted to cattle-raising in Iberia (usually in low density regimes 60 ), badgers are also known to avoid cattle in many other regions 61,62 due to disturbance. In Portugal, sheep and goats are mostly raised in flocks that move around the landscape, perhaps promoting higher concentrations of dung that increase dung beetle availability, a badger prey 48 . Finally, these livestock may also control shrub coverage 63 , which may prevent woodland encroachment onto badger-preferred herbaceous habitat. (2019) 9:3155 | https://doi.org/10.1038/s41598-019-39713-1 www.nature.com/scientificreports www.nature.com/scientificreports/ Climatic drivers of badger distribution. Our data showed that climate is an important driver shaping the distribution of rear-edge badger populations. Badgers have a higher probability of using areas with mild climatic characteristics, namely with intermediate precipitation regimes (between 800 and 1000 mm rainfall annually), and mild annual mean temperatures (between 15-16 °C) (Fig. 2).
There are two critical periods for badger survival during their lifetimes, i.e. the first months of life for cubs and over-winter survival for all age classes 22,64 . The first period is mostly affected by extended summer drought, whereas the second is predominantly dependent on winter frost, low temperatures and heavy rainfall leading to floods. In northwestern badger populations, mild winters enhance over-winter survival (e.g., 64 ), as animals (especially juveniles) have a better likelihood of maintaining their body weight and energy reserves. In the UK, Noonan and colleagues 65 found that badgers reduce their activity (and probably foraging bout length and frequency) when temperatures are lower, jeopardizing their efficiency in accumulating over-winter reserves. Other mesocarnivores www.nature.com/scientificreports www.nature.com/scientificreports/ and small carnivore species, such as raccoon dogs (Nyctereutes procyonoides) or least weasel (Mustela nivalis), exhibit similar strategies to cope with critical winter temperatures, due to the high costs of thermoregulation during activity 66,67 . Winter temperatures often drop below 0 °C in many regions of Portugal, perhaps inducing southwestern badger populations to adopt a strategy similar to that of their conspecifics at higher latitudes and reduce their over-winter activity. The biological costs of employing this behavioural strategy are: (i) reduced survival 68 or (ii) avoidance of areas with particularly harsh winters, i.e. those with lower annual temperatures. Both consequences would result in the same spatial pattern. Our results suggest that lower temperatures are more constraining for Portuguese badger populations than higher ones. Temperatures in Portugal can exceed 35 °C, contributing to mean annual temperatures around 15-16 °C, which we identified as promoting badger presence. Thus, it is possible that badger populations inhabiting this region may have developed local adaptations that allow them to benefit from more temperate conditions. The mechanistic basis for this spatial pattern may also be linked to food resource availability. Milder climates can influence the availability of two of the foods most consumed by badgers in Portugal, i.e. coleopterans and olives 48 . Mild temperatures may increase winter coleopteran survival (e.g. 69 ), thereby promoting higher species abundances. Furthermore, the reproductive structures and fruits of olive trees are sensitive to low temperatures, particularly frost 70 , so they present higher productivity in areas less affected by frost.
At this edge of the species distribution, the amount of rain may also be a more important driver of badger presence. Portugal is mostly characterized by a Mediterranean climate where rain mainly falls in winter and cyclic droughts occur 71 , with annual precipitation ranging from <400 mm in southeastern regions to >3000 mm in northwestern ones 71 . Badgers seem to prefer areas with mild rainy conditions (between 800 and 1000 mm of annual precipitation), likely due to the consequently higher availability of some feeding resources (e.g. 72 ). Intermediate levels of rainfall mean greater likelihood of avoiding food shortages associated with drought or arid environments 46,73 . Nouvellet and colleagues 68 showed that cub and juvenile survival were highest under conditions of intermediate levels of rainfall, but adult survival was mostly affected by the driest years, probably due to a decrease in food availability and quality in dry years 64,74 . However, excessive rainfall can affect thermoregulation during winter and early spring, especially when associated with lower temperatures, and it may constrain cub survival during the critical first months outside the sett 68 . Hypothermic stress associated with wetter conditions can debilitate a cub's immune system, often promoting endoparasitic infections 22 that may compromise cub survival and recruitment 22,68 . Moreover, depending on the soil and geological structure of the area, high rainfall can also compromise sett stability (e.g. in sandy soils) and habitability (e.g. flooding when sited in valleys or in clay-dominated soils 75,76 ). Setts are crucial structures for central-place foragers such as badgers, where animals rest during the day, interact to maintain social cohesion, and where cubs are born and reared 77,78 . Poor sett-building conditions affect species density 79 , especially in Mediterranean areas where sett sites are the main limiting factor constraining distribution 31 . www.nature.com/scientificreports www.nature.com/scientificreports/ Future impact of climate and landcover change on badger distribution. Badgers are central place foragers, whose ecology is intrinsically linked to sett locations 78 . They do not exhibit migratory movements that can lead to changes in their range limits, and so are more vulnerable to climate change 21 . However, badger populations at the northern limit of the species range might benefit from climate change that creates conditions for www.nature.com/scientificreports www.nature.com/scientificreports/ badgers to colonize environments historically inaccessible to them due to extreme weather (e.g. longer snow-free periods with consequently higher food availability 27,28 ). However, at its southern rear-edge range, badgers might experience the inverse pattern due to the combined effects of HIREC factors. As mentioned before, climate change scenarios for Portugal estimate a generalized reduction in annual mean precipitation (by 10% up to 2040 17 ) and an increase in temperature (~1. 5 °C 17 ). This forecasted climate change, together with the predicted changes in landscape composition 38 , will decrease the favourability of areas of southern Portugal for badgers, potentially leading to a range retraction northwards. This retraction will likely be matched by an increase in favourability for northeastern Portugal, where badgers will find better conditions to survive (Fig. 4). Although we forecast a contraction of the badger's southern range limit in Portugal, we estimate no overall difference in the percentage of areas in the country with higher favourability. Thus, loss of favourable areas in the south will be compensated for by more beneficial environmental conditions in the North-east.
These forecasted changes in distribution for the species in its southwestern rear-edge range can probably occur throughout the badger's southern distribution range (i.e. the Mediterranean), since the climate change predicted for Portugal is similar to that foreseen for the entire Mediterranean region 17 . Moreover, landscape changes seem likely to follow the same patterns across the region 38 . Nevertheless, further broad-range studies targeting the drivers of distribution of central and eastern Mediterranean badger populations should be prioritized, especially to confirm if the drivers we identified for Portuguese populations have a broader effect and to assess how badger distributions will evolve in those areas. Information covering the entire southern range limit will allow us to understand the ecological strategies badger populations need to adopt to survive in the environmentally challenging landscape of Mediterranean Europe and provide data that can make conservation strategies more effective.

Study area and sampling design.
To avoid the limitations associated with studies of local or even regional extent (i.e. calibration of models with limited variation of environmental and anthropogenic disturbance factors affecting model performance and predictability robustness for wider extents 14 ), we extended our analysis across all mainland Portugal. This is the first study to evaluate badger distribution and the factors determining it at a nationwide scale in the Mediterranean region. Furthermore, our study encompasses the high bioclimatic variability characteristic of Western Iberia, where Atlantic and Mediterranean biogeographical regions interconnect 80 , as well as high variation in landcover, topography and disturbance conditions. Western Iberia is characterized by a wide variety of climatic conditions typical of the two distinct bioclimatic regions covering the area: Atlantic (Cantabroatlantic sub-region) and Mediterranean (Sado-Divisorian, Luso-Extremaduran and Carpetano-Leonese sub-regions) 80 . Within the Mediterranean region, the climate is usually hot and dry in summer and humid cool in winter. Heavy rain occurs often, and summer droughts are common and sometimes prolonged 81 . In the Atlantic region, the climate is typically oceanic, with mild temperatures and high precipitation and humidity 82 (see Table 2 for details). Landcover is diverse, associated with the altitudinal variation (0-1993 m), and includes deciduous (e.g. Quercus spp.) and conifer (e.g. Pinus spp.) forests and exotic plantations (e.g. Eucalyptus sp.), scrublands, natural pastures and agricultural patches (e.g. orchards, olive groves, vineyards, agroforestry, etc. 16 ; see Table 2 for details). Mean population density for Portugal is 111.8 inhabitants/km 2 (2016 data 83 ), and the country has a fair coverage of highways (totaling 3,065 km) and 2-lane national, regional and municipal paved roads (totalling 14,313 km) (2016 data; www.pordata.pt/; see Table 2 for details). Cattle, sheep and goats are raised extensively in many regions, reaching average densities of 12.8, 24.0 and 4.4 ind./km 2 , respectively (National Statistics Institute, https://www.ine.pt/; see Table 2 for details).
We divided mainland Portugal (89,060 km 2 ) into 987 cells of 10 × 10 km, using the UTM reference system, fuse 29, on WGS84 datum (EPSG code: 32629) (Fig. 1). We then selected 180 regularly distributed cells, using the chess knight movement pattern (i.e. L-shaped in any direction), starting at the northwest corner of the country (Fig. 1). Cells located in the L tips were selected for badger sampling and were subdivided into four 5 × 5 km cells, of which we randomly selected two and defined five 500 m line transects/itineraries in each. Transects were not set in areas where badger presence is highly unlikely (e.g. rivers, dams, inside estuaries, beaches) or where much of the landscape is humanized (e.g. villages, industrial compounds). The spatial allocation of sampling transects was defined to proportionally represent, as much as possible, the landscape composition of each 5 × 5 km sampled cell based on landcover characteristics. They were defined manually over a landcover map, within a Geographical Information System, and we tried to correlate the transect length within a specific landcover unit with the approximate proportion of that unit within the sampled cell.

Survey of badger presence.
We surveyed all transects located in the 272 5 × 5 km cells (located in 136 10 × 10 km cells) between June 2014 and January 2017 to detect signs of badger presence. However, 38 of the 10 × 10 km cells, located in the southeastern part of the country, could not be sampled due to logistical limitations (i.e. we could sample ca. 78% of the pre-selected cells; Fig. 1). The remaining six 10 × 10 km cells were not sampled because they encompassed >75% of its area covered by sea, dams or were located within Spanish territory. Badger presence in each transect was confirmed based on signs of species presence, such as footprints, latrines, setts or fur samples found, for example, on barbed wire. Although expert-based identification of carnivore scats is prone to false positive and false negative errors 84,85 , badger scent-marking behaviour minimizes this bias and makes sign identification highly accurate as scats are mostly deposited in ground pits called latrines 78 . Badger setts-underground dens where badgers rest during the day and where their cubs are born and reared 59 -were identified based on the existence of other signs of badger presence in their vicinity and burrow size and structure 59 . When badger presence was confirmed in any transect, the corresponding 5 × 5 km cell was classified as positive.
Compilation of environmental and anthropogenic disturbance data. Each 5 × 5 km cell was characterized regarding its environmental and anthropogenic disturbance features, mostly based on remote sensing (2019) 9:3155 | https://doi.org/10.1038/s41598-019-39713-1 www.nature.com/scientificreports www.nature.com/scientificreports/ data. We first built a Geographical Information System (GIS) using several software tools (ArcGIS 10.4.1 86 ; Quantum GIS 2.14.9 87 ) and incorporating the following digital layers: landcover, road and highway network, human density, protected areas and hunting reserves, domestic ungulate densities, topography, soil types, lithology, and climatic data ( Table 2). Data analysis. We first assessed the spatial autocorrelation of badger presence data in the 5 × 5 km cells and model residuals using the Moran I index 88 , available in the R package "ape" 89 , to prevent poor inference and enhance the predictive ability of the models 90 . We then tested for data multicollinearity between all co-variates using the Variance Inflation Factor (VIF), to identify candidate variables that are collinear 91 . As there is no VIF factual cut off level, we used the values suggested by Zuur and colleagues 92 , and excluded all variables with VIF > 5. The VIF was recalculated for the remaining variables. The process was repeated until none of the retained variables reached VIF > 5.
We tested the factors potentially shaping badger distribution in Portugal using a Boosted Regression Trees (BRT) approach for each hypothesis (H1-H5, see Introduction). BRT combines decision trees and boosting 93,94 . It is based on the average of many prediction rules, achieved in a forward stage-wise procedure (a kind of additive regression model, wherein individual trees act as individual terms 95 ), instead of a single-rule prediction. The BRT procedure starts with a regression tree that focuses on minimizing the loss function. Then a new regression tree, containing (or not) variables and nodes distinct from the first tree, is fitted to the prediction residuals of the first tree. At this stage the model comprises two trees, and its residuals are estimated. The overall BRT model is a linear combination of all the generated trees 94 , so global fit is improved by encompassing the predictions of previous trees (weak learners) and focusing on observations incorrectly classified by those trees 93 . We selected this approach because BRT is insensitive to outliers, can fit nonlinear relationships, allows use of different types of variables (e.g. continuous and binary), and automatically models interactions between predictors 94,95 .
Following the recommendations of Elith and colleagues 94 and Elith and Leathwick 96 , we used a 10-fold cross-validation procedure and selected the largest learning rate (lr) and the smallest tree complexity (tc) to enable us to achieve a minimum of 1000 trees in the BRT fitting process (see Elith and colleagues 94 for more details regarding the BRT fitting procedure and lr and tc). When fitting the consecutive trees, non-informative variables were removed (i.e. the least important variables were excluded and the model was re-fitted in a process we repeated sequentially until no change was achieved in either the % deviance explained or Area Under the Curve -AUC; see below), leading to simplification of the set of variables 94 . The relative contributions of predictors (% importance -the frequency that a variable is selected in the BRT fitting procedure, scaled to sum 100) were calculated, and partial dependence plots were produced for the most important predictors, showing their effects on probability of badger occurrence after accounting for the average effects of other variables. BRT models were fitted using the R-package 'gbm' 97 .
Since we detected significant spatial autocorrelation among residuals (see Results), we adopted the methodology of Crase and collaborators 37 to incorporate this spatial structure in our BRT to minimize its effects. We added an autocovariate term into the BRT that already contained the environmental and anthropogenic disturbance variables, which accounted for the influence of neighbouring observations by specifying the relationship between the value of a cell and those located in its vicinity, thereby representing the spatial autocorrelation in the residuals 37 . We produced residuals autocovariate (RAC) models for each hypothesis, incorporating into BRT an autocovariate estimated from the residuals of BRTs produced using only the variables described in Table 2. The BRT procedure was the same as that described above and the RAC was estimated using the R package "raster" 98 .
To test the first four of our pre-defined hypotheses (H1-H4), we produced residuals autocovariate BRT models (RAC-BRT) for each hypothesis by combining all the non-correlated variables related to that hypothesis (see Table 2). We then identified the variables representing the 50% more influential predictors in each hypothesis (H1-H4, excluding the autocorrelation correction factor), based on the variables relative influence (i.e. a percentage representing the average number of times a variable is used to define a split of a tree branch, weighted by the improvement of the model fit due to that split 99 ). These variables were used to produce a hybrid hypothesis (H5), which was tested using the same methodological approach. Selection of the best hypothesis explaining the pattern of badger distribution was based on the Area Under the Curve (AUC, derived from the Receiver Operating Characteristic curve, or ROC) of the ensemble RAC-BRT models of each hypothesis 93 . The best model structural fit (i.e. % deviance explained) was also estimated.
Based on our modelling results, we first implemented a model-based interpolation process (i.e. a prediction of species presence in new cells that present a similar range of environmental characteristics to those of the sampled cells within the same time-period evaluated 34 ) to estimate badger distribution in the species southwestern range limit (i.e. Portugal). As RAC was introduced into the BRT models as a variables, we needed to assign RAC values to those 5 × 5 km cells not sampled to produce a predictability map. To do this, we assigned a residual mean value for each non-sampled cell to generate a predictability estimate. Badger presence predictability for mainland Portugal was estimated using the "predict.gbm" function available in the R package "gbm" 97 , which allows estimating predicted values from generalized boosted models. A raster layer was produced based on those predicted values and using the "raster" 98 package, which was exported to a Geographical Information System (Quantum GIS 2.14.987), where we created a predictability map.
Although producing a predictability map is important to understand species distribution and to define effective conservation plans, in regions were species presence may be more scattered or irregular (due to temporal variation of resource availability), as at the limits of a species' distribution, predictability may be less informative. In contrast, favourability, defined by Real and colleagues 100 as the "variation in the probability of occurrence of an event in certain conditions with respect to the overall prevalence of the event", may be a more adequate index to assess which regions might be more adequate to support a badger population given the regional context of the species' distribution. Since a favourability index of 0.5 indicates that cells/conditions have a probability of (2019) 9:3155 | https://doi.org/10.1038/s41598-019-39713-1 www.nature.com/scientificreports www.nature.com/scientificreports/ harbouring badgers equivalent to the overall presence of badgers in the entire dataset, the use of the favourability function allowed us to discriminate between cells that favour badger presence (F ≥ 0.50) and those that possess deleterious characteristics for badgers (F < 0.5) 101 . Thus, favourability is an important index in conservation biology and particularly for identifying routes of expansion or retraction. Favourability was estimated as described by Real and colleagues 100 and Acevedo and Real 101 , based on the predictability results and the number of presences (n 1 ) and number of absences (n 0 ).
We validated the predicted performance of the favourability map by matching it with previously recorded badger presence data [obtained non-systematically from other published or unpublished studies; mostly roadkills (e.g., 102 ), captures (e.g., 43 ) and camera-trapping (e.g., 103 ) data; Fig. S2, Supplementary Material], and estimated the percentage of false negatives, i.e. cells with a favourability less than 0.50 but where badger presence was confirmed. All statistical analysis were implement using R software 104 .
Finally, we forecasted the evolution of badger distribution in Portugal up to 2040. Based on our model results, we predicted the favourability of a territory to harbour badgers based on variables with the potential for change: landcover and climate (see Results). Soil and rock types were assumed to stay unchanged. We also opted to keep constant the densities of domestic ungulates because there are no available national predictions on how these variables may evolve up to 2040.
Land-use change scenarios for 2040 were based on predictions and data provided by Stürck and colleagues ( 38 ; http://labs.kh.hercules-landscapes.eu/labs/themeLD.html). These authors developed four scenarios [Libertarian Europe -A1; Eurosceptic Europe -A2; Social Democracy Europe -B1; European Localism -B2; see 38 for a detailed description of the scenarios]. As the landcover categories used in our study varied slightly from those described by Stürck and colleagues 38 , we grouped categories of their study that could be assigned according to those identified in our study as influential: Shrublands (semi-natural vegetation, recently abandoned arable land, and Heatland and moorlands 38 ); Herbaceous (Pasture and recently abandoned pasture land 38 ). Eucalyptus cover was assumed to stay constant since current Portuguese legislation prohibits an increase of these exotic plantations and wood/paper production is likely to continue.
Climate data predictions (i.e. annual precipitation and annual mean temperature; see Results) were obtained from the Intergovernmental Panel on Climate Change (IPCC) climatic dataset 17 , based on scenario A1B from the IPCC Special Report on Emission Scenarios (SRES 17 ), which assumes a global economy with a balanced use of energy systems (fossil and non-fossil 105 ). Climate change scenarios for Portugal estimate that in 2040 there will be a generalized reduction in annual mean precipitation (an average of 10% for the entire country 17 ). Inversely, temperatures are expected to rise, with most of the country showing an average increase of 1.5 °C 17 .
Based on these predicted scenarios, we estimated the values of the variables included in the best model for every 10 × 10 km grid cell in 2040 and created a favourability map based on the assessed model parameters, using the same methodology as detailed above.

Data Availability
All badger's presence data will be available at the "Atlas of Portuguese mammals" website database: http://atlas-mamiferos.uevora.pt/index.php/downloads/.