It depends on the device, and its way of connecting to the Internet.
If the device is a desktop computer, without any wireless connections, the IP address is used to determine the device's location, and the measurement is rather crude.
To determine the location of a laptop or other wireless device, Opera may in addition send the following data from nearby Wi-Fi access points: MAC address (uniquely identifies the hardware) and signal strength (tells how far away it is). A database of known Wi-Fi access points, together with measured signal strength, makes it possible to give rather precise location information. The success of this method depends largely on the concentration of known access points.
If the device is connected to a mobile telephone network, location data may include cell IDS of the cell towers closest to you, and their signal strength. If the device is GPS-enabled, the location may be obtained via GPS.
Any or all of the above methods may be used to determine the device's location, if the device has sufficient connectivity. In what follows, we refer to this data as the "location data". --Opera's Help page