I'm trying to work out how to open or add a wms layer to a map using arcpy.
I have the service url, the image name etc. I can open it manually, but I need to do this using arcpy. (Without saving a lyrx file etc)
Appreciate any assistance, thanks
Solved! Go to Solution.
Ok I came up with a hack solution, I opened one wms layer manually then created a layer file (.lyrx) for this. I then use this as a 'template', my python code replaces the image name text with the new image name, then I open that .lyrx file. Seems to work ok. It also requires the wms connection file (.wms) to be placed in the project folder, if the connection doesn't already exist for the project.
Hello,
What do you need to do with the WMS layer after open it? I possibly can help you download it to a location on your PC using arcpy.
Hi, I just want to add the image to the current map.
Same as if I opened it manually: https://pro.arcgis.com/en/pro-app/latest/help/data/services/add-wms-services.htm
Ok I came up with a hack solution, I opened one wms layer manually then created a layer file (.lyrx) for this. I then use this as a 'template', my python code replaces the image name text with the new image name, then I open that .lyrx file. Seems to work ok. It also requires the wms connection file (.wms) to be placed in the project folder, if the connection doesn't already exist for the project.
I was going to suggest something similar. Glad you got it worked out.