[GIS] Problems adding OSM layer

qgisqgis-openlayers-plugin

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?

Best Answer

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.

Related Question