score:5
Yes, that's the subway. According to Wikipedia, about 40% of the system runs on the surface or elevated tracks, even though the entire system is called the subway. Some portions in Queens are underground while others are above ground. Long Island Rail Road (LIRR) also runs through Queens on its own set of tracks, and there are even spots where the subway and LIRR cross on grade separated elevated tracks.
The elevated portions generally run on viaducts above the street. Your picture shows Queens Blvd. where there's nothing more interesting than parking or streets underneath (and stations). Here, with thanks to Michael Seifert, is a street-level view of the area shown in your photo; you can see there's quite a bit of distance between the tracks and nearby buildings. In dense areas, buildings can then be built next to or under these structures, giving the appearance of trains running on rooftops when you look from the right angle. Some cities have used more creative ways of combining retail and rail, such as Hackescher Markt in Berlin.
Upvote:3
It is indeed part of the New York City subway. It is the former-IRT "7 Flushing" line.
This line is former IRT and parts were built in coordination of competitor BMT, both private companies unlike the municipally-owned IND. Eventually the city bought out all the subway companies, creating one municipal system.
By the time it was built, lower/mid Manhattan residents had experienced more than enough elevated trains, in particular they were tired of those powered by steam; and they wanted the loud, ugly, filthy things gone. Electrification became possible around 1890, and railroads built in NYC needed to be electrified.
The IRT's claim to fame was that the parts of the line downtown run underground. (which isn't really feasible for steam, although London gave it a serious try.) They switch to elevated structures out in the boroughs where land values are lower, but it remains electrified. This subway section opened first in 1915, and it was extended outward into Queens, finishing 12 years later.
By this time, railroads everywhere saw electrification as "the way to go" if one could afford the significant costs of installation. Those costs are reasonable if the railroad is very short and very busy, as this one is.
The line is 102 years old - older than virtually all of the buildings. If a building had been in the way of building the line, then depending on cost the either the building would be bought out, or the line would be rerouted. Railroads also have power of eminent domain to take property they need, as do cities.
Buildings built under the elevated structures are not unheard of in New York City, but they certainly came after construction. A 1-2 floor building simply would not have enough real estate value to justify the considerable expense of building around a structure.