[Qgis-developer] RE: [Qgis-user] WMS in python?
wonder.sk at gmail.com
Sat Nov 15 13:53:09 EST 2008
On Thu, Nov 13, 2008 at 9:54 PM, Rob McCulley <RMcCulley at county24.com> wrote:
> I've revisited this again, and haven't managed to get it working yet.
> Anyone have any experience with adding a WMS layer using the python
Here's a simple example that I've used to connect to NASA's WMS server:
url = 'http://wms.jpl.nasa.gov/wms.cgi'
layers = [ 'global_mosaic' ]
styles = [ 'pseudo' ]
format = 'image/jpeg'
crs = 'EPSG:4326' # WGS 84
rlayer = QgsRasterLayer(0, url, 'some layer name', 'wms', layers,
styles, format, crs)
or if you want to load it directly from python plugin or python console in QGIS:
iface.addRasterLayer(url, 'some layer name', 'wms', layers, styles, format, crs)
But, there's a problem that you can't really access information from
GetCapabilities response, so you must check first what layers / styles
/ format want from what the server provides.
More information about the Qgis-developer