Route switching method for implementing wireless sensor network data query

The invention discloses a method and system for realizing data query route switching in wireless sensor network and network density collecting method. Wherein, the route switching method comprises: base station node receiving query request set by user; base station sending network density query instruction; base station integrating the classes of the user inputted query instruction after obtaining the network density information, and selecting route protocol to process current query; attaching the route information into the query instruction and sending the query instruction to sensor network; the sensor node in the network receiving the query instruction, then switching into the corresponding route protocol according to the route information attached in the query instruction; the network networking according to the route protocol, and returning the query result to the base station. Applying the method and system can reduce the energy consumption in wireless sensor network data query, and prolong the network life-cycle.