Salinization and alkalization are predominant environmental problem world-wide which their accurate assessment is essential for determining appropriate ways to deal with land degradation, for better soil and crop management. In the current research, a combination of random forests and covariate data were used to assess spatial variability of soil salinity and sodicity in 436 km2 agricultural salt-affected land in Kurdistan Province, Iran. Using the conditioned Latin hypercube sampling method, 295 soil samples were sampled across the study area, and then soil reaction (pH), electrical conductivity (EC), and sodium adsorption ratio (SAR) were measured. Covariate data including terrain attributes, remotely-sensed data, groundwater table, and categorical maps were acquired. Random forest (RF) models were used to predict the spatial distribution of pH, EC, and SAR by making a relationship between soil data and covariates. Furthermore, three optimization algorithms (particle swarm optimization-PSO, genetic algorithm-GA, and bat algorithm-BAT) were used to explore if the hybridized RF works better than the standard RF. Results of 10-fold cross-validation with 100 replications indicated that the accuracy of RF + PSO was higher for predicting pH (RMSE = 0.52 and R2 = 0.67), EC (RMSE = 2.32 dSm−1 and R2 = 0.57), and SAR (RMSE = 8.98 and R2 = 0.54, respectively) in comparison to the other implemented models. Furthermore, the results disclosed that the most important covariates to predict pH, EC, and SAR were groundwater table, categorical maps, salinity index, and multi-resolution ridge top flatness. Besides, the results indicated that the mean values for pH, EC, and SAR in lowland and bare land were significantly different from the other physiographic units and land uses, respectively. Importantly, the classified map of salt-affected soils highlighted areas with a high risk of exceeding critical threshold values of pH, EC, and SAR, which is located in the center of the study area, and showed that 6.30%, 3.1%, and 4.6% of the study area are saline-sodic soil, saline soil, and sodic soil, respectively. These up to date spatial soil information on severity of soil salinity and sodicity is crucial for agricultural management of affected areas and the proposed method can be used to the other similar regions.