Hi, I am using the batch request API for the first time.
I use the following eval script:
//VERSION=3
function setup() {
return {
input: [{
datasource: "s1grd",
bands: ["VV", "VH"]
}],
output: [ {
id: "VV_Median",
bands: 1,
sampleType: "UINT16"
}, {
id: "VH_Median",
bands: 1,
sampleType: "UINT16"
}],
mosaicking: Mosaicking.ORBIT
};
}
// Defines function to fetch the median of a value array
function getMedian(values){
if(values.length ===0) return 0;
values.sort(function(a,b){
return a-b;
});
var half = Math.floor(values.length / 2);
if (values.length % 2)
return values[half];
return (values[half - 1] + values[half]) / 2.0;
}
function evaluatePixel(samples) {
// Store samples from two different datasources into
// separate objects
var S1GRD = samples.s1grd;
// Initialise S1GRD VV and VH arrays
var vv_array = [];
var vh_array = [];
// Push values to arrays
for (var i = 0; i < S1GRD.length; i++) {
vv_array.push(S1GRD[i].VV);
vh_array.push(S1GRD[i].VH);
}
// Assign median to output variable
var median_vv = getMedian(vv_array);
var median_vh = getMedian(vh_array);
// Define evalscript responses
return {
VV_Median: [median_vv * 10000],
VH_Median: [median_vh * 10000]
};
}
"""
And the following code:
area_gdf = gpd.read_file(shape_file_path)
full_geometry = Geometry(area_gdf.geometry.values[0], crs=self.crs)
shb = SentinelHubBatch(self.config)
sentinelhub_request = SentinelHubRequest(
evalscript=evalscript,
input_data=[
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL1_IW,
time_interval=interval,
other_args={"id": "s1grd"}
),
],
responses=responses,
geometry=full_geometry,
config=self.config
)
batch_request = shb.create(
sentinelhub_request,
tiling_grid=SentinelHubBatch.tiling_grid(
grid_id=self.grid_id,
resolution=10,
buffer=(5, 5)
),
bucket_name=self.aws_bucket_name,
# Check documentation for more about output configuration options:
# output=SentinelHubBatch.output(...)
description='Builtup-checker-BatchProcessing'
)
shb.start_analysis(batch_request)
batch_request = shb.get_request(batch_request)
print(batch_request)
while (batch_request.status != BatchRequestStatus.ANALYSIS_DONE):
self.logger.info(f'{batch_request.status} {batch_request.request_id}')
time.sleep(20)
batch_request = shb.get_request(batch_request)
self.logger.info(f'Running this batch job will take about {batch_request.value_estimate:.4f} processing units')
However, the status never (canceled after 10+ min) changes from CREATED.
Is there anything I need to keep in mind?
Thanks for the help.
Oh and sorry if this is obvious and covered in the documentation. I did not find it