Exclude empty days from evalscript quary PlanetScope

Hi, some years ago I made a script to download Planet data based on aSentinelHub tutorial based on Example 8

It downloads all planet images available for the date range, but if there is no data (so no satellite flew over for that date) it gives me an “empty” file over the same extent. I say “Empty” because it returns NaN for the cloud masking part based on UDM2_Clear but it does give each pixel a value per band, which can add up in larger extents. Here is the evalscript:

evalscript_true_color = """

    function setup() {
        return {
            input: [{
                bands: ["Red", "Green", "Blue", "NIR", "UDM2_Clear"]
            output: {
                bands: 4 
                //sampleType: "FLOAT32"

    function evaluatePixel(sample) {
        // Scale the bands
        var scaledBlue = [2.5 * sample.Blue / 10000];
        var scaledGreen = [2.5 * sample.Green / 10000];
        var scaledRed = [2.5 * sample.Red / 10000];
        var scaledNIR = [2.5 * sample.NIR / 10000];

       if (sample.UDM2_Clear != 0)  { 
        return [
       } else {
        return [NaN, NaN, NaN, NaN]}

The issue is that this fills my memory when downloading many years of data. Is there a way to exclude those empty dates in the evalscript part? I use the same
print("Monthly time windows:\n") for slot in slots: print(slot)
part as in the example.

Hi, in the example that you used the dates are actually generated from the function in cell 38. I am not sure how you are generating your list of dates, but instead of this method you can make a Catalog API request of your AOI and time range to the data collection where your Planetscope data is. From this you can extract out the datetime field in the results and use this to create a list of dates for your request.

Hi. Indeed, I generate a list of dates like the function in ceel 38 of the example. Consequently, some dates that i download with the evalscript do not show any cell values.

I run this script once a week and want to download all available Plantescope images of the last 7 (or X) days. I see what you mean, but I don’t know how to code this.

I see there is a similar problem here Download of multiple images and dates in a specific time period - #2 by william.ray

the solution also refers to example 38, which takes the least cloudy image in a date range (in the example, one image per month for 12 months). However, it is still unclear how I can download all images in that date range.

I adapted the slots to run the get_true_color_request function for every day, as a new folder is made per day but the images are not named after that day (the folder is named after the date though). I need this for later steps when I want to select specific dates.

for now I’ll just download empty dates as well and delete them afterwards, but this does increase the usage of my processing units. If anybody has an alternative way I’d be happy to try it out.