1

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")
3
  • gis.stackexchange.com/questions/259897/…
    – Mapperz
    Commented Feb 24, 2020 at 20:50
  • can you explain the difference?
    – Mapperz
    Commented Feb 24, 2020 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
    Commented Feb 24, 2020 at 22:02

1 Answer 1

1

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")

QgsProject.instance().addMapLayer(my_layer)
1
  • That works perfectly, thanks for the clarification.
    – Arjan
    Commented Feb 25, 2020 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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