Saturday 15 October 2016

Adding ArcGIS-FeatureServer-Layer to QGIS using PyQGIS?


I have a password protected ArcGIS-FeatureServer Service, the service provides 25 layers.


Using "Add Layer --> Add ArcGIS-FeatureServer-Layer" works like it should.


Is there any way to add these kind of layers with PyQGIS? I could not find a documentation or example anywhere.


How to Add a normal WFS layer with PyQGIS is well documented.


For ArcGIS MapServer it is super-easy:


iface.addRasterLayer("url='my_featuere_layer_url' layer='0'", "mylayer", "arcgismapserver")


But the provider "arcgismapserver" is not documented anywhere, just found an example after some search, so I expect that there is a similar solution for ArcGIS-FeatureServer.



Answer



After all, the answer is quite simple (but nowhere documented):


uri = "crs='EPSG:25832' filter='' url='http://someurl.com/featureserver' table="" sql="
my_layer = QgsVectorLayer(uri, "layername", "arcgisfeatureserver")

The lack of documentation leads to a lot of other questions (bounding-box, username, password, ...)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...