Safety risk identification is the premise and foundation of safety risk management for railway construction. However, due to some characteristics of railway projects, which include large volumes of work, complex construction environments, and long construction cycles, etc., the risk factors of railway projects are often hidden in all stages of engineering construction. It results in the comprehensive identification of safety risks of railway projects being usually difficult, and this problem is more serious when the railway is constructed in complex and dangerous areas. Therefore, to identify the safety risks comprehensively, this paper constructs a safety risk identification method applicable to railway construction in complex and dangerous areas. This method studies the spatial and temporal distribution of risks and their relationship with subprojects by using a work breakdown structure (WBS), a risk breakdown structure (RBS), grid-based management, and forming a safety risk identification matrix, which can help researchers analyze the characteristics of risks. In order to verify the effectiveness of the method, the CZ Railway, which is located in the Sichuan and Tibet provinces of China, crossing the Hengduan Mountains with a total length of 1838 km, was selected as a case study, and risk identification for its civil engineering was carried out. The research results show that in the construction process of the CZ Railway, the main types of safety risks suffered by various branch projects were different. In addition, some risk factors only appeared at specific times in space, and there is a strong interaction between these risk factors. Based on this method, safety risk identification can intuitively discover the spatial and temporal distribution of risk factors and analyze the interaction between risk factors, which can provide help for the formulation of targeted risk control measures.