Modern satellite positioning primarily uses global navigation satellite system (GNSS) signals collected by multiple satellites and obtains specific location information through calculations. However, the nonlinear propagation of the signal between the satellite and receiver caused by reflection or scattering due to buildings forms a non-line-of-sight (NLOS) signal, which significantly degrades positioning accuracy. Therefore, distinguishing and eliminating NLOS signals is the best way to improve the accuracy of modern satellite navigation. Initially, algorithms and physical models were established to eliminate NLOS signals. Then, some machine learning models were developed that appeared to be able to better solve the problem, such as the gradient boosting decision tree, support vector machine, convolutional neural network (CNN), and long short term memory (LSTM) network. However, adapting the same model to different environments and the fine extraction of the original features of the signal are challenges that remain unresolved. Therefore, this paper proposes a neural network based on the attention mechanism, called the environmental transformer (ET), that can extract both the satellite visibility features of the signal and the environmental features around the GNSS signal receiver. In the binary classification task of distinguishing between NLOS and LOS signals, an ET can reach an accuracy of 87.45%, which is higher than that of previously mentioned models. The results also show that the adaptability of an ET to different environments has greatly improved. This paper also explains the working principle of an ET through attention visualization.