The Revelation contains hundreds of references and allusions to the Hebrew scriptures. (An exact count varies from one commentator to the next.) He quotes, paraphrases, and adapts parts of the scriptures so often and so thoroughly, we can safely say the author knew the Hebrew scriptures inside and out.
In Deuteronomy 28 contains the sanctions of the covenant held over Israel. In the event of disobedience to the covenant, a variety of punishments will be brought against Israel, and verses 28.27 and 28.60 compares a disobedient Israel as worthy of the same plagues that came on Egypt during the exodus. A similar instance occurs in Amos 4.10.
Comparisons of Israel, Judah, or Jerusalem to that of Sodom (and Gomorrah) are more frequent and direct: Deuteronomy 29.23; Isaiah 1.9-10; 3.8-9; Jeremiah 23.14; Ezekiel 16.1-2,44-58; Amos 4.11; Lamentations 4.6.
While the statement that Jerusalem is 'spiritually' equivalent to Sodom and Egypt is very brief in the Revelation, it is very probable the author was drawing influence from the Hebrew scriptures, and compressed it into a single thought.