Designing an onshore wind farm layout poses several challenges, including the effects of terrain and landscape characteristics. An accurate model should be developed to obtain the optimal wind farm layout. This study introduces a novel metaheuristic algorithm called Modified Electric Charged Particles Optimization (MECPO) to maximize wind farms’ annual energy production (AEP) by considering the different terrain and landscape characteristics of the sites. Some non-uniform scenarios are applied to the optimization process to find the best combination of decision variables in the wind farm design. The study was initiated by a uniform wind farm layout optimization employing identical wind turbine hub heights and diameters. Following this, these parameters underwent further optimization based on some non-uniform scenarios, with the optimal layout from the initial uniform wind farm serving as the reference design. Three real onshore sites located in South Sulawesi, Indonesia, were selected to validate the performance of the proposed algorithm. The wind characteristics for each site were derived from WAsP CFD, accounting for the terrain and landscape effects. The results show that the non-uniform wind farm performs better than its uniform counterpart only when using varying hub heights. Considering the impacts of the terrain and landscape characteristics, it is observed that sites with a higher elevation, slope index, and roughness length exhibit a lower wake effect than those with lower ones. Moreover, the proposed algorithm, MECPO, consistently outperforms other algorithms, achieving the highest AEP across all simulations, with a 100% success rate in all eight instances. These results underscore the algorithm’s robustness and effectiveness in optimizing wind farm layouts, offering a promising avenue for advancing sustainable wind energy practices.