Clip token protected WCS layer

01-07-2019 06:01 AM
New Contributor III

I am trying to create a geoprocessing service that let you created a buffer and use that buffer to clip a WMS service I published on my Portal.

The WMS service is protected and I managed to get to the service using a token but I cannot find a way to download the data.

This is my code, what am I doing wrong?

import arcpy
from arcpy import env
import requests
import json
from json import loads, dumps

env.outputCoordinateSystem = arcpy.SpatialReference(4326)

Point = arcpy.GetParameterAsText(0)
Buffer ="in_memory/Buffer"
Dist = 100
Distance = str(Dist) + " Meters"

outBuffer = arcpy.Buffer_analysis(Point, Buffer, Distance)

arcpy.SetParameter(1, outBuffer)

for row in arcpy.da.SearchCursor(outBuffer, ["SHAPE@"]):
   extent = row[0].extent
   XMin = str(extent.XMin)
   YMin = str(extent.YMin)
   XMax = str(extent.XMax)
   YMax = str(extent.YMax)

   coordinates = XMin + "," + YMin + "," + XMax + "," + YMax

resp ="",
   data={"username":"xxxxx", "password":"xxxxx",

tokenCode = str(json.dumps(resp.json()["token"]))

mapService = "" + coordinates + "&FORMAT=GTiff" + "?f=json&token=" + tokenCode

arcpy.SetParameter(2, mapService)

0 Kudos
1 Reply
New Contributor III

I think I have problems building the request. After looking at the results I received back from the server I changed the request to: 

However I get the error message that " parameter COVERAGE is invalid" even if passed the name of the layer.

0 Kudos