In order to detect and correct node localization anomalies in wireless sensor networks, a hierarchical nonuniform clustering algorithm is proposed. This paper designs a centroid iterative maximum likelihood estimation location algorithm based on nonuniformity analysis, selects the nonuniformity analysis algorithm, gives the flowchart of node location algorithm, and simulates the distribution of nodes with MATLAB. Firstly, the algorithm divides the nodes in the network into different network levels according to the number of hops required to reach the sink node. According to the average residual energy of nodes in each layer, the sink node selects the nodes with higher residual energy in each layer of the network as candidate cluster heads and selects a certain number of nodes with lower residual energy as additional candidate cluster heads. Then, at each level, the candidate cluster heads are elected to produce the final cluster heads. Finally, by controlling the communication range between cluster head and cluster members, clusters of different sizes are formed, and clusters at the level closer to the sink node have a smaller scale. By simulating the improved centroid iterative algorithm, the values of the optimal iteration parameters
α
and
η
are obtained. Based on the analysis of the positioning errors of the improved centroid iterative algorithm and the maximum likelihood estimation algorithm, the value of the algorithm conversion factor is selected. Aiming at the problem of abnormal nodes that may occur in the process of ranging, a hybrid node location algorithm is further proposed. The algorithm uses the
ℓ
2
,
1
norm to smooth the structured anomalies in the ranging information and realizes accurate positioning while detecting node anomalies. Experimental results show that the algorithm can accurately determine the uniformity of distribution, achieve good positioning effect in complex environment, and detect abnormal nodes well. In this paper, the hybrid node location algorithm is extended to the node location problem in large-scale scenes, and a good location effect is achieved.