So I’m trying to use the scripts provided by the request builder to retrieve data with sentinelhub python. For some reason it keeps throwing Error 400, though.
config = SHConfig()
config.sh_client_id = xx
config.sh_client_secret = xx
evalscript = """
//VERSION=3
function setup() {
return {
input: [
{
bands: ["B01","B02","B03","B04","B05","B06","B07","B08","B8A","B09","B11","B12"],
units: "REFLECTANCE",
}
],
output: [
{
id: "default",
bands: 12,
sampleType: "AUTO",
},
],
mosaicking: "SIMPLE",
};
}
function evaluatePixel(samples) {
return {
default: [sample.B01,sample.B02,sample.B03,sample.B04,sample.B05,sample.B06,sample.B07,sample.B08,sample.B8A,sample.B09,sample.B11,sample.B12],
};
}
"""
bbox = BBox(bbox=[15.62174, 46.6803, 15.63014, 46.68603], crs=CRS.WGS84)
geometry = Geometry(geometry={"type":"Polygon","coordinates":[[[15.62339,46.68603],[15.62273,46.68505],[15.623,46.68499],[15.62216,46.68236],[15.62174,46.68205],[15.62268,46.68217],[15.62289,46.68263],[15.62344,46.68258],[15.62356,46.68244],[15.62337,46.68205],[15.62331,46.68128],[15.62423,46.68115],[15.62425,46.68112],[15.62476,46.68152],[15.62475,46.68225],[15.62597,46.68208],[15.62633,46.68159],[15.62701,46.68125],[15.62842,46.68039],[15.6284,46.6804],[15.62914,46.6803],[15.62971,46.68069],[15.62969,46.68098],[15.63014,46.68218],[15.63011,46.68252],[15.628,46.68341],[15.62764,46.68306],[15.62694,46.6836],[15.62544,46.68399],[15.62371,46.68391],[15.62341,46.68402],[15.62358,46.68461],[15.62405,46.68499],[15.62339,46.68603]]]}, crs=CRS.WGS84)
request = SentinelHubRequest(
evalscript=evalscript,
input_data=[
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL2_L2A,
time_interval=('2021-01-05', '2021-01-05'),
other_args={"dataFilter": {"mosaickingOrder": "leastRecent"}}
),
],
responses=[
SentinelHubRequest.output_response('default', MimeType.TIFF),
],
bbox=bbox,
geometry=geometry,
size=[512, 509.07],
config=config
)
response = request.get_data()
Interestingly, the following evalscript actually works, but I don’t understand why, exactly:
evalscript = """
//VERSION=3
function setup() {
return {
input: ["B01","B02","B03","B04","B05","B06","B07","B08","B8A","B09","B11","B12"],
output: { bands: 12 }
};
}
function evaluatePixel(sample) {
return [sample.B01,sample.B02,sample.B03,sample.B04,sample.B05,sample.B06,sample.B07,sample.B08,sample.B8A,sample.B09,sample.B11,sample.B12];
}
"""