Whether portraying a criminal underworld or a high–school utopia, Chicago always looks right at home on the silver screen.

The city of the Dark Knight
The man in black is stood way up, on the ledge of the 90th floor of America's tallest building. His cape swirls in the wind that screams around the tower and he looks grimly down upon the city. The lights of the skyscrapers below glow like burning cigarette ends through the murk of twilight. The man knows that the darkness brings to the surface the detritus of this city - the criminal, the psychotic. And only he can stop them. He takes a breath and hurls himself off the building, swooping deep into the gloaming until he disappears from view. The man is Batman, and the city is Gotham - home of the American nightmare.

Of course, the people who actually live here don't see it quite like that. The Gotham of Christopher Nolan's The Dark Knight is actually Chicago, and for the residents of the Windy City, having their city chosen to depict urban dystopia is just another thing to be proud of. Up at the viewing platform of the Willis (formerly Sears) Tower, the staff are used to movie stars wandering around. This was where Nolan decided Christian Bale's Batman should survey the city before making his stomach-churning leap. And the 442-metre-high tower has continued to be put to good cinematic use.

'A few months ago, some scenes for the new Transformers movie were filmed here,' says Dave Lacki, a Willis Tower guide. 'They had guys jumping off the roof and gliding down to that car park there.' He points at what from this distance looks like a tiny square on a piece of graph paper. 'They dropped down outside this window. It was pretty special.'

Chicago's skyline certainly makes for a terrific establishing shot. This city is the home of the skyscraper. The first in the world, the Home Insurance Building, was built in 1885 on South LaSalle Street. Ever since, Chicago has been a laboratory for architectural experimentation, a celebration of engineering ingenuity and the joys of building something really, really tall. In 1974, Chicago sealed its reputation with the completion of the Sears Tower, then the world's biggest building.

The cityscape today is a sheet of steel stalagmites, scored with the trails of highway lights curving around the rim of Lake Michigan. Like New York, this is a classic American metropolitan landscape, testifying to the relentless march of money and modernism that built this nation. But unlike the instantly recognisable New York, there's something intangible about Chicago. It looks familiar and yet hard to place - a city that's on the tip of your tongue, remaining just out of reach.

That's why it's such a popular choice as a movie location, according to Maria Roxas, a location manager on Batman Begins. 'Zoom out, and people know it's Chicago,' she says. 'Zoom in, and it could be any big city. Chicago is a city of different levels - the tallest building in the US, street level, and underground roads.' She's referring to Lower Wacker Drive, the subterranean haulage network which staged car chases in both of Nolan's Batman films.

The city of rhythm and blues
The prominence of Chicago as a film set is a relatively recent development. Mayor Richard J Daley, who was in office from 1955 to 1976, was adamant that Hollywood should not be allowed to invade the city. He feared that film makers would focus solely on the grubbier aspects of Chicago's history - guns, gangs and gangsters. So it was not until Jane M Byrne took over the mayoralty in 1979 that Chicago began to offer up its streets to the big screen - starting with The Blues Brothers.

Dan Aykroyd, the film's co-star, said in 2005 that 'Chicago is one of the stars of the movie. We wrote it as a tribute.' And the film, in which a couple of street-rat blues musicians attempt to get their old band back together, certainly features a stream of familiar city locations, from Wrigley Field baseball stadium to East 95th Street Bridge. But The Blues Brothers also acted as Chicago's olive branch to the film industry. The authorities were so obliging to director John Landis - even letting him crash a car into the mayor's own building, the Daley Centre, narrowly missing the huge Picasso sculpture in the forecourt - that the city instantly shot up directors' hotlists. Here was a city you could have fun with.

The Blues Brothers is one long celebration of the Chicago music scene. Chicago's South Side was a haven for African-Americans fleeing the virulently racist South. And it was from here that blues music began to seep into the popular consciousness via local labels such as Chess Records.

The Blues Brothers acknowledged this heritage by filming its famous Shake Your Tail Feather dance scene in the South Side, with Ray Charles providing the accompaniment. A mural depicting some of Chicago's blues heroes was painted on the wall of a pawn shop, Shelly's Loan Co - rebranded as Ray's Music Exchange for the movie - and the pavement became the dancefloor. The mural's still there, a little faded, but nonetheless a symbol of Chicago's significance in the history of pop music.

The South Side used to be full of small blues joints, where veteran bluesmen would bark lyrics of lovelorn pain. Nowadays, the best place to experience the atmosphere that so entranced John Belushi and Dan Aykroyd is on the North Side, at Rosa's Lounge. Set up by Italian blues fanatic Tony Mangiullo in 1984, Rosa's is a narrow dive bar with large posters of famous visitors plastered on the walls - including a young, even thinner, Barack Obama. Unlike the more commercial clubs, Rosa's is a throwback to the roots of Chicago blues. 'I wanted to recreate the spirit that I found in South Side bars like Theresa's [revered blues bar] when I first moved here,' says Tony. 'The people there were so friendly, even though I didn't speak any English. So I wanted Rosa's to be the friendliest blues bar in town.' Judged by the convivial atmosphere amongst the barflies here tonight, shooting pool and clambering up on stage to knock out a solo, he's not gone far wrong.

The city of high school dreams
For all The Blues Brothers' success, its tale of cop-dodging music fiends didn't do much to allay Mayor Daley's fear that movies would portray Chicago in a dodgy light. It took the emergence of the man who would become Chicago's most successful homebred director to offer reassurance. Starting with his 1984 directorial debut, Sixteen Candles, John Hughes released a succession of movies in which he turned his hometown into a high school utopia. And huge hits like Ferris Bueller's Day Off, The Breakfast Club and Home Alone imprinted this image on the minds of a million teenagers across the planet.

Hughes spent his own adolescence in Northbrook, a quiet suburban town a few miles north of the city. Northbrook was historically known as Shermerville, and Hughes tried to use the name in nearly all of his films. Ferris Bueller, Home Alone and The Breakfast Club were all set in 'Shermer', the town acting as an avatar of Chicago's North Shore suburbs - a place where high school dreams could come true.

Up at Winnetka - the luxuriously prim suburb where the house of Kevin 'Home Alone' McCallister's family can be found - wide, winding avenues lined with oak and ash trees lead to serene estates of grand houses set back from the road. Some really do have white picket fences. It's exactly the kind of place where you expect to see paper boys riding bikes and lobbing newspapers into gardens. Further north at Glencoe, on the verge of Lake Michigan, there is the unexpected boon of a secluded beach, looking back across the water to the city. This is where Ferris took his friend Cameron in a vain effort to cheer him up.

Many of the suburban estates here are underscored by a network of shallow ravines, pretty micro-valleys of flowers and the odd deer wandering about. One of these ravines, in Highland Park, had a starring role in Ferris Bueller's Day Off. The minimalist glass box which acted as Cameron's house hangs precariously over the ravine. It was through these windows and down into the ravine that Cameron famously released his father's red Ferrari.

According to Billy Higgins, a location scout for Ferris, the original script had Cameron drive the car into a tree. 'But when John saw the house, he was so excited by the thought of the car falling into the ravine that he rewrote the entire script around that location,' he says. I meet Billy on the set of The Vow, a new Hollywood movie being filmed at another location that features prominently in Ferris, the Art Institute. Pedestrians wait on the side of the road while numerous takes of Rachel McAdams running across the bridge that connects the Institute to the Millennium Park are shot. They're used to it. 'This is nothing,' says one. 'When Transformers was here, they shut down Michigan Avenue [Chicago's equivalent to Oxford Street] and filled it with rubble and robots.'

The city of gangsters
Big Al stands at the door of the Green Mill cocktail lounge, rapping a wad of dollars against his broad knuckles. His head is brutally shaved and his small moustache has been carefully waxed to a point. Around his neck hangs a single bear's claw. 'Six dollars,' he growls to the young couple who have just come through the door. 'Don't talk during the band.' The couple hand over the money and walk towards the bar, looking as if they'll never speak again, let alone tonight. Big Al has worked the door here longer than he cares to remember, and he's insistent that the atmosphere at the Green Mill remains exactly how it was when a certain other Big Al was a regular here in the 1920s.

'That was Capone's booth right there,' he says, pointing towards a red velvet enclave at the corner of the bar. 'Sitting there, he could see the front and the side door at all times. As soon as he came in, the doors were locked and no one could enter or leave. And whatever the band were playing when he arrived, they stopped mid-song, and started playing his favourite, Rhapsody in Blue.'

Even today, Green Mill couldn't be more gangster if it insisted everyone wore trilbies and carried violin cases. It's like walking into a scene from Goodfellas - the crowd seated at candlelit tables, suited-up waiting staff distributing Old Fashioneds, the band on stage playing whipsmart swing and jazz. It's not surprising that such an atmospheric club has made numerous celluloid appearances, from being blown up in James Caan's Thief to acting as John Cusack and Jack Black's hangout in High Fidelity.

By the 1990s, Chicago had started to capitalise upon, rather than avoid, its gangster history. Sixty years after the city had been in the control of Al Capone, Bugsy Malone et al, a string of films were released that recreated the cat-and-mouse chase between the police and gangsters. The most successful was Kevin Costner and Robert De Niro's The Untouchables - the key scene of which was shot on the stairs of Union Station, where Costner raced to catch a runaway pram.

In 2008, director Michael Mann pushed historical verisimilitude to new heights when he took over the entire Lincoln Park block that houses the Biograph Theatre, now Victory Gardens Biograph Theatre. The Biograph was the cinema that legendary bank robber John Dillinger was leaving in July 1934 when he was gunned down by police, after being set up by his date, Anna Sage, known as the 'woman in red'. Mann was fastidious in his quest for accuracy while making Public Enemies, his Johnny Depp-starring Dillinger biopic. Every shopfront on the block was transformed to look as it did in Dillinger's day; even the smallest item in the shop windows was replaced by its 1930s counterpart. No doubt much to the set designer's chagrin, Mann then proceeded to shoot the assassination scene entirely at night.

The city of the 'L'
Chicago has taken the same approach to public transport as it has to architecture - the higher, the better. The 'L' (for 'elevated') might look like a monorail from a 1950s funfair, but it remains the crucial link in Chicago's infrastructure. The roar of carriages thundering along the tracks that arch above the Loop, the city's financial district, turns a walk around town into a surround-sound experience: the trains rattling above, the growls of the cars at street level, the distant rumble of the subway beneath the sidewalk.

The 'L' trains are resolutely utilitarian, with sheet-metal skins and formica seats - an appropriately gritty means of getting about what is at heart a bluecollar city. It is no surprise that the majority of its appearances on screen have been in thrillers or as a signifier of urban alienation. In The Sting, Robert Redford leaps off the roof of the 43rd Street station to escape the police, while Harrison Ford favours the 'L' as a good place for a punch-up in The Fugitive. John Cusack's existential crisis in High Fidelity is given an edge of metropolitan misery by his journeys on the 'L', staring out of the window, contemplating his chances with Catherine Zeta-Jones.

Chicago certainly has an uneasy relationship with the 'L'. Take a ride on the Brown Line, the secondoldest 'L' route and it's easy to understand why adverts for new suburban housing estates say things like 'living close to the 'L' shouldn't mean a metre away'. The tracks pass so close to the surrounding apartments - like the one belonging to Blues Brother Elwood - that a passenger could reach through a window and switch off a buzzing alarm clock.

But the Brown Line also acts as a fast-track to the core of Chicago. The train slips between the skycrapers like a snake in the grass, before nipping across the river to the Magnificent Mile shopping district. It then rolls onto Wrigleyville, home of the terminally unlucky Chicago Cubs baseball team.

This route makes up the final section of John Candy and Steve Martin's torturous journey in John Hughes's Planes, Trains and Automobiles, a film about two Chicagoans who are desperate to get home in time for Thanksgiving.

Of all the Chicagos that have appeared on the big screen - a Gotham of tall shadows and low lives, the Blues Brothers' town of rhythm and blues, or the glamorous demi-monde of Al Capone - as the train heads towards the crisp silhouette of the Loop, it is Hughes's vision that rings true. This really is a city you'd travel halfway across the world to come home to.

The article 'Chicago’s celluloid city' was published in partnership with Lonely Planet Magazine.