From this post, Invalid QgsRasterLayer when attempting to load a Google Static Maps API image into QGIS this block of code can be used to load a Google Static Maps API image into QGIS (using the QGIS Python Console):
>>> reg = QgsMapLayerRegistry.instance()
>>> raster = QgsRasterLayer('http://maps.googleapis.com/maps/api/staticmap?center=51,0&zoom=10&size=2550x3300', 'test')
>>> raster.isValid()
>>> reg.addMapLayer(raster)
This works on Windows (tested versions QGIS 2.14.21 and QGIS 2.18.15). However, this does not appear to work on Mac (tested versions 2.18.9 and 2.14.20) or Linux (version 2.18.13). On Mac or Linux, and invalid raster object is returned.
This is not specific to the Google Static Maps API, an invalid raster object is returned with other http image urls.
Any ideas on how to get this working on Mac/Linux?
No comments:
Post a Comment