Although wild boar invasion is a common human–wildlife conflict worldwide, it is difficult to solve. Understanding the characteristics of wild boar invasion into farmland, accurately predicting the areas where wild boar invasions will occur, and implementing effective prevention and control measures are key to effectively alleviating conflicts between humans and wild boars. From 2021 to 2023, we conducted field surveys and experimentally determined the effectiveness of prevention and control measures in the Huanan and Tonghe Counties in order to explore the landscape and farmland factors affecting wild boar invasion, as well as to evaluate the effectiveness of different combinations of prevention and control measures. The results indicate that the mean patch area, patch area coefficient of variation, and forest type edge density show positive linear correlations with the invaded area, which is positively associated with the presence of ditches and negatively correlated with the existence of electronic fences. Meanwhile, there are non-linear relationships between invasion and the edge density of farmland type, the proportion of forests, the Shannon uniformity index, the proportion of residential areas, the distance from the village, the distance from the forest, and the population density. In particular, the risk of wild boar invasion is higher in the border area between forest and farmland. The loss rate of farmland under the different control measures (compound) was significantly lower than that in the electronic fence group (single) (p < 0.05). Based on these findings, we put forward the following suggestions for the prevention and control of wild boar: (1) widen and deepen the narrow landscape elements around farmland; (2) focus on the border area between forest and farmland; and (3) use compound prevention and control measures. This study provides a comprehensive foundation for future wild boar prevention and control research, and it contributes to the formulation of effective wild boar prevention and control policies worldwide.