Designing and optimizing the structure of urban transportation networks is a challenging task. In this study, we propose a method inspired by optimal transport theory and the principle of economy of scale that uses little information in input to generate structures that are similar to those of public transportation networks. Contrarily to standard approaches, it does not assume any initial backbone network infrastructure but rather extracts this directly from a continuous space using only a few origin and destination points, generating networks from scratch. Analyzing a set of urban train, tram and subway networks, we find a noteworthy degree of similarity in several of the studied cases between simulated and real infrastructures. By tuning one parameter, our method can simulate a range of different subway, tram and train networks that can be further used to suggest possible improvements in terms of relevant transportation properties. Outputs of our algorithm provide naturally a principled quantitative measure of similarity between two networks that can be used to automatize the selection of similar simulated networks.