I installed OpenLayers plugin successfully in QGIS 2.2 Valmiera, but when I add OpenStreetMap layer, the following error message appeared as a Python error popup window:

An error has occurred while executing Python code:

> Traceback (most recent call last):   File "C:/Users/I Wayan
> Mudita/.qgis2/python/plugins\openlayers_plugin\openlayers_plugin.py",
> line 50, in addLayer
>     self.__plugin.addLayer(self)   File "C:/Users/I Wayan Mudita/.qgis2/python/plugins\openlayers_plugin\openlayers_plugin.py",
> line 202, in addLayer
>     self.__setMapSrsGoogle()   File "C:/Users/I Wayan Mudita/.qgis2/python/plugins\openlayers_plugin\openlayers_plugin.py",
> line 261, in __setMapSrsGoogle
>     extMap = coodTrans.transform(extMap, QgsCoordinateTransform.ForwardTransform) QgsCsException: forward
> transform of (-985846.534752, -198190.645686) PROJ.4: +proj=longlat
> +datum=WGS84 +no_defs +to +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs Error: latitude or longitude exceeded limits

Python version:

2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]

QGIS version:

2.2.0-Valmiera Valmiera, c3a2817

Python path:

['C:/PROGRA~1/QGISVA~1/apps/qgis/./python/plugins\processing', 'C:\Users\I Wayan Mudita\.qgis2\python\plugins\GeoCoding', 'C:/PROGRA~1/QGISVA~1/apps/qgis/./python', u'C:/Users/I Wayan Mudita/.qgis2/python', u'C:/Users/I Wayan Mudita/.qgis2/python/plugins', 'C:/PROGRA~1/QGISVA~1/apps/qgis/./python/plugins', 'C:\PROGRA~1\QGISVA~1\bin\python27.zip', 'C:\PROGRA~1\QGISVA~1\apps\Python27\DLLs', 'C:\PROGRA~1\QGISVA~1\apps\Python27\lib', 'C:\PROGRA~1\QGISVA~1\apps\Python27\lib\plat-win', 'C:\PROGRA~1\QGISVA~1\apps\Python27\lib\lib-tk', 'C:\PROGRA~1\QGISVA~1\bin', 'C:\PROGRA~1\QGISVA~1\apps\Python27', 'C:\PROGRA~1\QGISVA~1\apps\Python27\lib\site-packages', 'C:\PROGRA~1\QGISVA~1\apps\Python27\lib\site-packages\PIL', 'C:\PROGRA~1\QGISVA~1\apps\Python27\lib\site-packages\win32', 'C:\PROGRA~1\QGISVA~1\apps\Python27\lib\site-packages\win32\lib', 'C:\PROGRA~1\QGISVA~1\apps\Python27\lib\site-packages\Pythonwin', 'C:\PROGRA~1\QGISVA~1\apps\Python27\lib\site-packages\Shapely-1.2.18-py2.7-win32.egg', 'C:\PROGRA~1\QGISVA~1\apps\Python27\lib\site-packages\wx-2.8-msw-unicode', 'C:\Users\I Wayan Mudita\.qgis2\python\plugins\DigitizingTools\tools', 'C:\PROGRA~1\QGISVA~1\apps\qgis\python\plugins\fTools\tools']

What is wrong here?

2 Answers 2


Openlayers plugin only works with EPSG:3857. Usually it sets the CRS automatically, but this fails sometimes.

To avoid the error, first set the project CRS to EPSG:3857, then load the OpenStreetMap Layer via the plugin.

It might be that one of your existing layers can not be reprojected to EPSG:3857:

transform of (-985846.534752, -198190.645686) from latlon to merc will not work.

  • Doesn't QGIS always automatically switch to 3857 when you add an OpenLayers plugin layer?
    – Simbamangu
    Commented May 12, 2014 at 5:02
  • 1
    It tries to, but when the existing layers data can't be reprojected, you get this error message. Might be a wrongly assigned CRS in one of those.
    – AndreJ
    Commented May 12, 2014 at 5:22

The best way to deal with projections in QGIS is in my opinion to save each layer as: EPSG 3857. And label them as such.

Then open them up in QGIS and then open up the OSM layer. It should work fine.

To make sure it's fine, check each of the layers CRS by selecting "properies/general" to make sure they're projecting in 3857. Then disable on the fly reprojection, and if everything is lining up right you've done it correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.