Can someone tell me how to add a ArcGIS FeatureServer to a QGIS plugin? I've found a post here on how to add maplayers which is simple enough but I can't find an description on how to do the same for FeatureServer layers. I'm trying to build a plugin to load a large number of various WMS, WFS, maplayer, featureserver datasets in QGIS without having to manually load them.

example: https://services2.arcgis.com/chCSiGO4ORzXeSGk/arcgis/rest/services/Archeologie__Onderzoeken/FeatureServer

maplayer syntax that works:

iface.addRasterLayer("url='my_featuere_layer_url' layer='0'", "mylayer", "arcgismapserver")
  • can you explain the difference? – Mapperz Feb 24 at 21:52
  • The question is basically the same, the solution provided doesn't work for the current version of Qgis so I made my own post. If that's not what should be done please ignore me flagging the post. I've tried the solution provided (uri = "crs='EPSG:25832' filter='' url='someurl.com/featureserver' table="" sql=" my_layer = QgsVectorLayer(uri, "layername", "arcgisfeatureserver") but that doesn't work so I posted this in the hope of getting some help. I'm a complete newbie in creating plugins, python and programming in general so this forum is my lifeline. – Arjan Feb 24 at 22:02

To find the correct uri you can load the layer manually in QGIS 3 in the browser window / ArcGISFeatureServer and than look at the layer properties on information tab, there is the source written.

In your example you have to set the layernumber

uri="crs='EPSG:28992' url='https://services2.arcgis.com/chCSiGO4ORzXeSGk/arcgis/rest/services/Archeologie__Onderzoeken/FeatureServer/0'"
my_layer = QgsVectorLayer(uri, "layername", "arcgisfeatureserver")

| improve this answer | |
  • That works perfectly, thanks for the clarification. – Arjan Feb 25 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.