BARCELONA, Spain — The streets here offer a glimpse of what the future may have to offer.

Alongside the city’s world-famous architecture and pristine sandy beaches, sensors attached to trash cans now alert workers when they need to be emptied.

The irrigation systems built into Barcelona’s parks monitor soil moisture and turn on sprinklers when water is needed. And drivers can use a smartphone application to find the nearest available parking spot in the labyrinthine streets.

“It’s crucial that these new technologies are useful to our citizens,” Xavier Trias, Barcelona’s mayor, said in his stately offices, which date from the 15th century. “It’s an important change. We have to create a sustainable system.”

Barcelona is among a number of European cities adopting new forms of technology aimed at improving services. More important, the investments, including neighborhoodwide high-speed Internet connections and electricity charge points for cars and motorbikes, offer ways to cut energy use and generate income.