> > Can a WMS Layer be added to an application built using the python
> bindings?
> >
> >
> >
> > I've tried to do it using a few variations of parameters with the
> > QgsDataSourceURI(), but my lyr.isValid() is always false.
> >
> >
> >
> > Can I add a WMS Layer using the python bindings, and if so, how?
> 
> It *should* be possible. There's a following constructor (available
> also from python) of raster layers which is used in case of WMS:
> 
>   QgsRasterLayer(int dummy,
>                  const QString & baseName = QString(),
>                  const QString & path = QString(),
>                  const QString & providerLib = QString(),
>                  const QStringList & layers = QStringList(),
>                  const QStringList & styles = QStringList(),
>                  const QString & format = QString(),
>                  const QString & crs = QString(),
>                  const QString & proxyHost = QString(),
>                  int proxyPort = 80,
>                  const QString & proxyUser = QString(),
>                  const QString & proxyPass = QString());
> 
> I have never done something with WMS so can't supply you with a
> working example, but to get an idea how to fill in the parameters, see
> QgisApp::addWmsLayer() and debug output from QgisApp::addRasterLayer()
> in src/app/qgisapp.cpp.
> 
> Regards
> Martin

Right you are Martin.  A WMS layer can be added via the python bindings
by using gdal.  I just had to set up an .xml file describing the wms
server as outlined here:  http://www.gdal.org/frmt_wms.html

Then it was a simple matter of adding the layer:

rLayer = QgsRasterLayer('data/local_wms.xml','2007 Aerial')

And everything worked perfectly.  The gdal wms provider doesn't seem
quite as fast as the native wms provider in QGIS, which isn't really a
surprise.  It works though.

Thanks for the tips!

Rob
_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-user

Reply via email to