A reliable transportation system is essential for the development of a community. Especially in urban transportation, rail transportation is a faster, more comfortable way to travel for the commuters. These benefits can be valued further when the rail transportation system is with zero emissions. Electric trains can be considered a zero-emission transportation method. However, a rail transportation system operates with net-zero emissions when electricity is generated from zero-emission-based sources. Photovoltaic systems have already been integrated into railway stations and spare land owned by railways to achieve net-zero emissions. Furthermore, medium-voltage DC network and microgrid concepts have been proposed to incorporate more renewable energy sources into railway electrification systems. However, the energy generated from those systems is not enough to realise net-zero emissions, as the power requirements of an urban railway electrification system are high. Accordingly, this article investigates the possibility of implementing a photovoltaic system along the railway tracks to meet the energy demands of an urban railway electrification system so that net-zero emissions can be achieved. Other significant advantages of the proposed photovoltaic system are lower feeder losses due to distributed photovoltaic systems integrated into the railway electrification system, lower conversion losses due to the direct integration of the photovoltaic system into the railway electrification system, and the nonrequirement of additional space to install the photovoltaic system. In this paper, a photovoltaic system capacity sizing algorithm is proposed and presented by considering a railway electrification system, the daily schedule of trains, and historical photovoltaic weather data. This proposed photovoltaic system capacity sizing algorithm was evaluated considering a section of the urban railway network of Sri Lanka and a three-year, 2017-2020, photovoltaic weather data. The results indicated that the potential for photovoltaic generation by installing photovoltaic systems along a railway track is much higher than the requirement, and it is possible to meet the required train scheduling options with proper sizing. Furthermore, in the three-year analysis, it is possible to achieve 90% of the energy required for the railway electrification system with effective train scheduling methods.