The invention discloses an unmanned aerial vehicle route planning and obstacle avoidance method, which comprises the steps of S1, establishing a two-dimensional space model, and setting space model data according to a flight starting point and a flight ending point; S2, obtaining a global offline air route by utilizing the space model data, and setting a flight air route as a global offline air route; S3, the unmanned aerial vehicle flying along the flight route, and monitoring whether a dynamic obstacle appears on the flight route or not in real time through a sensor; S4, when a dynamic obstacle appears, entering the next step; if no dynamic obstacle appears and the flight end point is not reached, entering the step S3, and if the flight end point is reached, entering the step S8; s5, initializing a pigeon flock algorithm by adopting an adjoint matrix method with constraints, and then performing local airway planning by using the pigeon flock algorithm; s6, smoothing the local air route by using the B spline curve; s7, the flight route being a combination of a global offline route and a local route, and executing the step S3; and S8, completing a flight mission, and ending the process.