hello! I am trying to download a mosaic corresponding to my area of interest (specifying the coordinates of my polygon). Everything is going fine until I try to visualize the data. I fail in this part. specifically on the second line (when I declare the viable tar). If you can help me find the error I would really appreciate it. Thank you.@batic @max.kampen .
response = oauth.post(f"{url}/api/v1/process", headers=headers, json = request)
tar = tarfile.open(fileobj=io.BytesIO(response.content))
userdata = json.load(tar.extractfile(tar.getmember(‘userdata.json’)))
userdata.
Before that, i made this:
from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session
# Your client credentials
client_id = ‘xxxx’
client_secret = ‘xxxx’
# Create a session
client = BackendApplicationClient(client_id=client_id)
oauth = OAuth2Session(client=client)
oauth.fetch_token(token_url=‘https://services.sentinel-hub.com/oauth/token’,
-
client_id=client_id, client_secret=client_secret)*
url = ‘https://services.sentinel-hub.com’
evalscript = “”"
//VERSION=3
function setup() {
- return {*
- input: [“B02”, “dataMask”],*
- mosaicking: Mosaicking.ORBIT,*
- output: {*
-
id: "default",*
-
bands: 1*
- }*
- }*
}
function evaluatePixel(samples, scenes, inputMetadata, customData, outputMetadata) {
- //Average value of band B02 based on the requested scenes*
- var sumOfValidSamplesB02 = 0*
- var numberOfValidSamples = 0*
- for (i = 0; i < samples.length; i++) {*
- var sample = samples[i]*
- if (sample.dataMask == 1){*
-
sumOfValidSamplesB02 += sample.B02*
-
numberOfValidSamples += 1*
- }*
- }*
- return [sumOfValidSamplesB02 / numberOfValidSamples]*
}
function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
- outputMetadata.userData = {*
- “inputMetadata”: inputMetadata*
- }*
- outputMetadata.userData[“orbits”] = scenes.orbits*
}
“”"
request = {
- “input”: {*
-
"bounds": {*
-
"properties": {*
-
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"*
-
},*
-
"geometry": {*
- “type”: “Polygon”,*
- “coordinates”: [*
- [*
-
[*
-
-7.19013464948524,*
-
37.1950340145669*
-
],*
-
[*
-
-7.17017478002351,*
-
37.1323029962586*
-
],*
-
[*
-
-7.44961295248773,*
-
37.0866804374889*
-
],*
-
[*
-
-7.60644049825846,*
-
37.5571630748011*
-
],*
-
[*
-
-7.30419104640941,*
-
38.0048344327285*
-
],*
-
[*
-
-7.11884940140763,*
-
38.0818225006523*
-
],*
-
[*
-
-7.37262488456391,*
-
38.3783691326551*
-
],*
-
[*
-
-7.35266501510218,*
-
38.6834699944273*
-
],*
-
[*
-
-7.05041556325313,*
-
38.9914222661226*
-
],*
-
[*
-
-7.1644719601773,*
-
39.0427476447384*
-
],*
-
[*
-
-7.32129950594803,*
-
39.3278886370489*
-
],*
-
[*
-
-7.12740363117694,*
-
39.441945033973*
-
],*
-
[*
-
-6.73961188163476,*
-
39.467607723281*
-
],*
-
[*
-
-6.2349123252453,*
-
39.2394949294326*
-
],*
-
[*
-
-5.21695898269707,*
-
39.6244352690517*
-
],*
-
[*
-
-4.07069219360915,*
-
39.6443951385134*
-
],*
-
[*
-
-3.902459008146,*
-
39.5160816919737*
-
],*
-
[*
-
-2.87024861598225,*
-
40.1947172536726*
-
],*
-
[*
-
-2.38265751913142,*
-
40.1120263659025*
-
],*
-
[*
-
-2.12317921612893,*
-
39.9038734415159*
-
],*
-
[*
-
-2.04904255812821,*
-
39.3335914568951*
-
],*
-
[*
-
-2.63073018244149,*
-
38.538048088349*
-
],*
-
[*
-
-3.29510869452479,*
-
38.4097346418093*
-
],*
-
[*
-
-4.01366399514707,*
-
38.4411001509634*
-
],*
-
[*
-
-4.45848394315133,*
-
38.2215415868844*
-
],*
-
[*
-
-5.22836462238949,*
-
38.1816218479609*
-
],*
-
[*
-
-6.03816504055111,*
-
38.0561598113444*
-
],*
-
[*
-
-6.34326590232326,*
-
38.0304971220364*
-
],*
-
[*
-
-6.59418997555644,*
-
37.8537097068039*
-
],*
-
[*
-
-6.82800558925099,*
-
37.7966815083419*
-
],*
-
[*
-
-7.19013464948524,*
-
37.5172433358776*
-
],*
-
[*
-
-7.28993399679389,*
-
37.3604157901069*
-
],*
-
[*
-
-7.19013464948524,*
-
37.1950340145669*
-
]*
- ]*
- ]*
} -
},*
-
"data": [*
-
{*
-
"type": "sentinel-2-l2a",*
-
"dataFilter": {*
-
"timeRange": {*
-
"from": "2018-10-01T00:00:00Z",*
-
"to": "2018-10-20T00:00:00Z"*
-
}*
-
}*
-
}*
-
]*
- },*
- “output”: {*
-
"width": 512,*
-
"height": 512,*
-
"responses": [*
-
{*
-
"identifier": "default",*
-
"format": {*
-
"type": "image/jpeg",*
-
"quality": 80*
-
}*
-
}*
-
]*
- }*
}
headers = {
- ‘Content-Type’: ‘application/json’,*
- ‘Accept’: ‘application/x-tar’*
}