This building was once a factory for the Knox Hat Company, one of the most well-known hatters of the early 20th century. Edward Knox, after recovering from serious injuries sustained during his service in the Civil War (for which he was awarded a Congressional Medal of Honor), returned to New York and took the reins of the family business. Over the years he expanded their operations from retail into manufacturing, and, in 1890, built this factory here in Brooklyn. It sat dormant for decades, suffering from decay and vandalism, before being renovated and turned into subsidized housing in the 1980s.
The life's work of Arthur and Cynthia Wood, Broken Angel was cited for numerous building code violations after a fire in 2006, and the Woods were forced to dismantle an incredible, multi-story rooftop structure they had built. For a look at many of the building's unique features, check out this photo gallery posted by the Woods' son, Chris. The NY Times also has a terrific shot of the whole complex.
Cynthia died in 2010 after a battle with liver cancer, and Arthur lives here alone now. Brandon Stanton spent some time with him last summer, and wrote about the experience for his Humans of New York project.
This line was abandoned in 1949, but there are still a couple of surviving sections of track. The elevated structure above is the Myrtle Avenue Line (M train), a remnant of the old Myrtle Avenue El.
CORRECTION: It's a subway vent! More info here.