In recent years, Unmanned Aerial Vehicle (UAV) remote sensing has developed rapidly in the field of farmland information monitoring. Real-time and accurate access to farmland information and crop growth dynamics is a prerequisite for the implementation of precision agriculture. Machine Learning identifies existing knowledge to acquire new knowledge, promotes the development of Artificial Intelligence, and brings a large number of data training sets for Machine Learning. The present work aims to ensure the safe operation of agricultural information systems and guarantee the data security of intelligent agriculture. The Machine Learning method explores the wireless network deployment of the UAV system. The geographical location deployment of agricultural information security can effectively carry out rapid security detection of agricultural information security. Firstly, the UAV-assisted information acquisition system was studied. Besides, a Double Deep Q-network (DDQN) algorithm for location deployment based on Geography Position Information (GPI) was proposed to quickly optimize the deployment location of UAVs. GPI can avoid the complicated calculation process of channel state information. The DDQN algorithm was introduced to obtain the functional relationship between GPI and the optimal UAV deployment position, forming a new GPI-Learning strategy. In addition, the Convolutional Neural Network (CNN) and Long Short-Term Memory (LSTM) are integrated as the CNN-LSTM algorithm to build the intrusion detection system for agricultural IoT for agricultural. In the integrated network structure of the system, LSTM is responsible for data transmission, and CNN is capable of network model building. Combined with the influence of various parameters on the performance of the UAV deployment location algorithm, the simulation experiment set the population size as 36, the discovery probability as 0.25, the step scaling factor as 0.8, and the Levy flight index as 1.25. The network throughput performance of the GPI-Learning algorithm combined with Cuckoo Search was better than other algorithms under different numbers of UAVs. On the KDD-CUP99 data set, the accuracy and detection rate of the agricultural IoT intrusion detection system based on the CNN+LSTM algorithm reached 93.5% and 94.4%, respectively. In general, the agricultural IoT intrusion detection system reported here has crucial practical reference value for the safe operation of agricultural information systems.