Hi Andrea, Yes, thank you! I only tried it about 2 hours ago and the second example worked perfectly.
I'm sure the first works, I could not create a valid Uri based on the documentation alone. Thank you for your help and checking in and apologies for the slow reply. Cheers Andrew On Mon, 6 Jun 2022, 5:54 pm Andrea Giudiceandrea, <[email protected]> wrote: > Hi Andrew, > have you received my replay to your question? Have you managed to solve > your problem? > > Best regards. > > Andrea > > > -------- Messaggio Inoltrato -------- > Oggetto: Re: [Qgis-user] PyQGIS - OGCFeatureService / QgsVectorLayer > "OAPIF" > Data: Fri, 3 Jun 2022 12:12:14 +0200 > Mittente: Andrea Giudiceandrea <[email protected]> > A: [email protected] > > > Andrew Hughes ahhughes at gmail.com > > Thu Jun 2 21:37:03 PDT 2022 > > > The following returns False, and has no features. Can someone please tell > > me what I am doing wrong - this seems so simple and really there is > > nothing I can think of that is wrong with this, but doesn't work? > > > > QgsVectorLayer(' > > > https://services.arcgis.com/quV9d0y7GW2PJkRl/arcgis/rest/services/rpt_spv_str_restr_prod_ogcfl/OGCFeatureServer > ', > > "layer_name", "OAPIF").isValid() > > Hi Andrew, > a clue is in the "OGC API - Features data provider (oapif)" section of > the QgsVectorLayer class detailed description at > https://api.qgis.org/api/classQgsVectorLayer.html > > Both the 'url' and the 'typename' parameters of the uri are mandatory > for the OAPIF driver. > > So you need to construct an uri with at least both such parameters: > e.g. > > QgsVectorLayer("url=' > https://services.arcgis.com/quV9d0y7GW2PJkRl/arcgis/rest/services/rpt_spv_str_restr_prod_ogcfl/OGCFeatureServer' > > typename='0'","layer_name", "OAPIF").isValid() > > or > > service_uri = QgsDataSourceUri() > service_uri.setParam("url"," > https://services.arcgis.com/quV9d0y7GW2PJkRl/arcgis/rest/services/rpt_spv_str_restr_prod_ogcfl/OGCFeatureServer > ") > service_uri.setParam("typename","0") > QgsVectorLayer(service_uri.uri(),"layer_name", "OAPIF").isValid() > > Best regards. > > Andrea Giudiceandrea >
_______________________________________________ Qgis-user mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
