Statistical API Error

Dear Sentinel HUB Team

I get this error from statistical API:

DownloadFailedException: Failed to download from:
with ReadTimeout:
HTTPSConnectionPool(host=‘services.sentinel-hub.com’, port=443): Read timed out. (read timeout=120.0)
There might be a problem in connection or the server failed to process your request. Please try again.

I previously generated a NDVI dataset for a bigger region with the same resolution and had 0 issues. Now my request generated 18000 processing units which makes 0 sense. There shouldn’t be any issues with the script, resolution or the coordinates being used, however for some reason I’m getting this big issue. Would appreciate any help.

Here are my coordinates

“Polygon”, “coordinates”: [ [ [ 64.9624773, 53.6415724 ], [ 64.8697731, 53.682368 ], [ 64.8018969, 53.7586091 ], [ 64.8010456, 53.7600276 ], [ 64.8005057, 53.763413 ], [ 64.8176027, 53.7961203 ], [ 64.8334635, 53.8198039 ], [ 65.2885292, 54.1163861 ], [ 65.4077554, 54.1604193 ], [ 65.4195035, 54.1644614 ], [ 65.4210592, 54.1639704 ], [ 65.431332, 54.159267 ], [ 65.479653, 54.127581 ], [ 65.6899744, 53.888248 ], [ 65.6886035, 53.8839349 ], [ 65.0157938, 53.6503533 ], [ 64.9624773, 53.6415724 ] ] ]

evalscript = """
//VERSION=3
function setup() {
  return {
    input: [{
      bands: [
        "B04",
        "B08",
        "SCL",
        "CLM",
        "dataMask"
      ]
    }],
    output: [
      {
        id: "data",
        bands: 1
      },
      {
        id: "dataMask",
        bands: 1
      }]
  }
}

function evaluatePixel(samples) {
    let ndvi = (samples.B08 - samples.B04)/(samples.B08 + samples.B04)

    var validNDVIMask = 1
    if (samples.B08 + samples.B04 == 0 ){
        validNDVIMask = 0
    }

    var noWaterMask = 1
    if (samples.SCL == 6 ){
        noWaterMask = 0
    }

    // masking cloudy pixels
    let combinedMask = samples.dataMask
    if (samples.CLM > 0) {
        combinedMask = 0;
    }

    const f = 5000;
    return {
        data: [toUINT(ndvi, f)],
        // Exclude nodata pixels, pixels where ndvi is not defined and water pixels from statistics:
        dataMask: [combinedMask * validNDVIMask * noWaterMask]
    }
}

function toUINT(product, constant){
  // Clamp the output to [-1, 10] and convert it to a UNIT16
  // value that can be converted back to float later.
  if (product < -1) {
    product = -1;
  } else if (product > 10) {
    product = 10;
  }
  return Math.round(product * constant) + constant;
}
request = SentinelHubStatistical(
    aggregation=SentinelHubStatistical.aggregation(
        evalscript=evalscript,
        time_interval=("2018-01-01", "2024-01-01"),
        aggregation_interval='P14D',
        resolution=[0.0004, 0.0004],        
    ),
    input_data=[
        SentinelHubStatistical.input_data(
            DataCollection.SENTINEL2_L2A, mosaicking_order = 'leastCC'
        ),
        
    ],
    geometry=Geometry(geometry, crs=CRS.WGS84),
    config=config
)

request = SentinelHubStatistical(
    aggregation=SentinelHubStatistical.aggregation(
        evalscript=evalscript,
        time_interval=("2018-01-01", "2024-01-01"),
        aggregation_interval='P14D',
        resolution=[0.0004, 0.0004],        
    ),
    input_data=[
        SentinelHubStatistical.input_data(
            DataCollection.SENTINEL2_L2A, mosaicking_order = 'leastCC'
        ),
        
    ],
    geometry=Geometry(geometry, crs=CRS.WGS84),
    config=config
)

Hi,

I had a look into your request and it does not appear abnormal to me that your request would use 21000 processing units. This is a large area of interest and you are returning data over a 6 year time span. This is likely why the request timed out too.

You could try optimising the request by inserting a cloud cover filter so that images that are cloudy are excluded from the analysis.

We recommend using the Batch Statistical API when handling this amount of data

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.