Select to view content in your preferred language

Adding WFS to webmap using Python API

1216
5
Jump to solution
09-05-2023 07:19 AM
Labels (2)
RoryMacGregor
New Contributor II

Has anyone has success using the Python API to add OGC WFS data to webmaps? Either directly or by creating a new item on AGOL and then adding that?

I am unable to get the add_layer() method of the WebMap class to work with WFS type items as I get a 'layers' KeyError.

I have tried adding a 'layers' attribute to the object which, interestingly, shows when I use dir() on the object but returns the same KeyError when I try and access item.layers.

Any help appreciated.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
David_McRitchie
Esri Contributor

Hey Rory,

Apologies but checking more into this via the arcgis.mapping.ogc documentation this will not be supported with wfs layers. Instead it will need to be a WMTS or WMS layer that is used.

I think this would be a good case to raise to ArcGIS Ideas as it might be something that could be included in a future release for the ArcGIS API for Python.

Many thanks,

David

 

 

Esri UK -Technical Support Analyst

View solution in original post

5 Replies
David_McRitchie
Esri Contributor

Hey Rory,

The add_layer method should be correct for this so it could be a data issue.

Could you check the following guide if you have not already? - https://developers.arcgis.com/python/samples/publish-ogc-services/

If this doesn't help then could you please share your WMS service and I can test on my side.

Many thanks,

David

Esri UK -Technical Support Analyst
0 Kudos
RoryMacGregor
New Contributor II

Hi David,

Thanks for getting back to me.

I have followed that guide and published the WFS using python. That works. However, I cannot then add the published WFS to a webmap using the add_layer method in the Python API. I can add the layer to a webmap using ArcGIS online in the browser but to do this for every webmap we need to update would be very labour intensive.

This is the url for the WFS: https://api.agrimetrics.co.uk/geoservices/datasets/fb8da72f-4938-4100-ac91-d9b8438ffd4c/wfs?request=...

If you could test it and see if you have the same issue, I would be very grateful!

Best regards,
Rory

0 Kudos
David_McRitchie
Esri Contributor

Hey Rory,

Apologies but checking more into this via the arcgis.mapping.ogc documentation this will not be supported with wfs layers. Instead it will need to be a WMTS or WMS layer that is used.

I think this would be a good case to raise to ArcGIS Ideas as it might be something that could be included in a future release for the ArcGIS API for Python.

Many thanks,

David

 

 

Esri UK -Technical Support Analyst
RoryMacGregor
New Contributor II

Hi David,

Thanks for clarifying this for us, at least we know where we stand. So, As far as you know, there is no way to automate adding wfs data to webmaps using the Python API? I will take your advice and suggest it for a future API update.

Best,
Rory

0 Kudos
David_McRitchie
Esri Contributor

That is correct Rory I do not think this is possible via the Python API, of course, I would love to be proven wrong on this.

Thanks,

David

Esri UK -Technical Support Analyst