Process API, Browser and request builder is getting img in black

Good evening,

I am using the API of Planet so I used the requests builder website to test API using the collection id of Planet. When I sent the request the results were black. I followed all the steps in your video tutorial but the results were the same in black. The same problem I have in Python and EO Browser. (Whatever the format of img is PNG, TIFF and JPEG and whatever the coordinates are…)

evalscript = “”"
//VERSION=3
function setup() {
return {
input: [{“bands”: [“Blue”, “Green”, “Red”,“dataMask”]}],
output: { bands: 4}
}
}
function evaluatePixel(sample) {
return [2.5 * sample.Red / 10000,
2.5 * sample.Green / 10000,
2.5 * sample.Blue / 10000,
sample.dataMask]
}
“”"
bbox = BBox(bbox=[12.479470997397163, 41.90998800134053, 12.480441997404082, 41.910589001340924], crs=CRS.WGS84)
geometry = Geometry(geometry={“coordinates”:[[[
12.479470997397211,
41.90998800134053
],
[
12.480441997404082,
41.90998800134069
],
[
12.480441997404032,
41.910589001340924
],
[
12.479470997397163,
41.910589001340746
],
[
12.479470997397211,
41.90998800134053
]]],“type”:“Polygon”}, crs=CRS.WGS84)

Hi @antonio.santos.rodri ,

Could you please share your request body, i.e., the payload?

Thank you.

Thanks for answer me.

This is script may only work with sentinelhub.version >= ‘3.4.0’

from sentinelhub import SentinelHubRequest, DataCollection, MimeType, CRS, BBox, SHConfig, Geometry

Credentials

config = SHConfig()
config.sh_client_id = ‘’
config.sh_client_secret = ‘’
evalscript = “”"
//VERSION=3

function setup() {
return {
input: [“Blue”, “Green”, “Red”],
output: { bands: 3 }
};
}

function evaluatePixel(sample) {
return [sample.Red/3000, sample.Green/3000, sample.Blue/3000];
}
“”"
bbox = BBox(bbox=[12.44693, 41.870072, 12.541001, 41.917096], crs=CRS.WGS84)

request = SentinelHubRequest(
evalscript=evalscript,
input_data=[
SentinelHubRequest.input_data(
data_collection=DataCollection.define_byoc(‘my_collection_id’), // private collection
time_interval=(‘2022-07-25’, ‘2022-08-25’),
),
],
responses=[
SentinelHubRequest.output_response(‘default’, MimeType.JPG),
],
bbox=bbox,
size=[512, 343.697],
config=config
)

response = request.get_data()

Hi @antonio.santos.rodri ,

I checked your data collection and the only one having data ingested is My PlanetScope 4-band data. It should work If you use its collection id (76xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx78) in your script.

Hi,

Yes I am using it but it isn’t working. It isn’t even working in the EO Browser. (I think something happen in the intern configuration of band).

Hi @antonio.santos.rodri ,

I couldn’t reproduce your error. I took the bounding box from your first post, which is the area you purchased for the data, and used the evalscript you provided. The request works fine. Could you try the below request using the Requests Builder?

curl -X POST https://services.sentinel-hub.com/api/v1/process 
 -H 'Content-Type: application/json'
 -H 'Authorization: Bearer <token>' 
 -d '{
  "input": {
    "bounds": {
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              12.479470997397211,
              41.90998800134053
            ],
            [
              12.480441997404082,
              41.90998800134069
            ],
            [
              12.480441997404032,
              41.910589001340924
            ],
            [
              12.479470997397163,
              41.910589001340746
            ],
            [
              12.479470997397211,
              41.90998800134053
            ]
          ]
        ]
      }
    },
    "data": [
      {
        "dataFilter": {
          "timeRange": {
            "from": "2022-07-25T00:00:00Z",
            "to": "2022-08-25T23:59:59Z"
          }
        },
        "type": "byoc-<collection_id>"
      }
    ]
  },
  "output": {
    "width": 975.938,
    "height": 811.691,
    "responses": [
      {
        "identifier": "default",
        "format": {
          "type": "image/jpeg"
        }
      }
    ]
  },
  "evalscript": "//VERSION=3\nfunction setup() {\nreturn {\ninput: [{bands: [\"Blue\", \"Green\", \"Red\",\"dataMask\"]}],\noutput: { bands: 4}\n}\n}\nfunction evaluatePixel(sample) {\nreturn [2.5 * sample.Red / 10000,\n2.5 * sample.Green / 10000,\n2.5 * sample.Blue / 10000,\nsample.dataMask]\n}"
}'

The area displayed in your EO Browser window is not the area you purchased for the data, so there’s no data.

Yes the area displayed in my EO Browser window is not the area I purchased for the data because i show u another example to see that it isn’t working also I will try it now I attached the img of the result.

Hi @antonio.santos.rodri ,

Yes, the bounding box used in the request covers the entire area you purchased from PlanetScope. There’s no data outside of this area. The resolution of PlanetScope is 3m, which is the same as the resolution of the image returned from the request.

Did something your purchase not align with your expectations? If so, please can you explain the issue a bit clearer?

Thank you.

My problem is that every coordinates I put the result is black in the request builder or Python using API of Planet but If I change it to Sentinel it worked.
Also i try to use EO Browser and do the effect of true color o false color nothing is working. (I tried to change and use customer and put bunds by myself and it didn’t work).
If I use the same coordinates with sutinelhub it worked but with Planet no. The result all time in black.
If you didn’t understand me we could do meeting and explain to you.
Thanks

This is script may only work with sentinelhub.version >= ‘3.4.0’

from sentinelhub import SentinelHubRequest, DataCollection, MimeType, CRS, BBox, SHConfig, Geometry
import os
from PIL import Image

def descargarImg(request):
for folder, _, filenames in os.walk(request.data_folder):
for filename in filenames:
print(os.path.join(folder, filename))
request.save_data();

Credentials

config = SHConfig()
config.sh_client_id = ‘-----’
config.sh_client_secret = ‘-----’

def convertirImagen(archivoImagen,archivoDestino):
im=Image.open(archivoImagen)
im.save(archivoDestino)

“”"
parametros poligono tienen qu
“”"

def buscarImg(cord1, cord2, cord3, cord4, fechaIni, fechaFin, nombreCarpeta, tipo):
if tipo==“trueColor”:
evalscript = “”"
//VERSION=3
function setup() {
return {
input: [{“bands”: [“Blue”, “Green”, “Red”]}],
output: { bands: 3}
}
}
function evaluatePixel(sample) {
return [2.5 * sample.Red / 10000,
2.5 * sample.Green / 10000,
2.5 * sample.Blue / 10000]
}
“”"
elif tipo==“GNDVI”:
evalscript = “”"
//VERSION=3
function setup() {
return {
input: [“Green”, “NIR”, “dataMask”],
output: { bands: 4}
}
}
function evaluatePixel(sample) {
var GNDVI = index(sample.NIR , sample.Green)
return valueInterpolate(GNDVI,
[0.0, 0.3, 1.0],
[
[1, 0, 0, sample.dataMask],
[1, 1, 0, sample.dataMask],
[0.1, 0.3, 0, sample.dataMask],
])
}
“”"
elif tipo==“NVDI”:
evalscript = “”"
//VERSION=3
function setup() {
return {
input: [“Red”, “NIR”, “dataMask”],
output: { bands: 4}
}
}
function evaluatePixel(sample) {
var NDVI = index(sample.NIR , sample.Red)
return valueInterpolate(NDVI,
[0.0, 0.3, 1.0],
[
[1, 0, 0, sample.dataMask],
[1, 1, 0, sample.dataMask],
[0.1, 0.3, 0, sample.dataMask],
])
}
“”"
elif tipo==“falseColor”:
evalscript = “”"
//VERSION=3
function setup() {
return {
input: [{
bands: [“NIR”, “Red”, “Green”]
}],
output: {
bands: 3,
sampleType: “FLOAT32”
}
}
}
function evaluatePixel(sample) {
return [sample.NIR / 10000,
sample.Red / 10000,
sample.Green / 10000]
}
“”"

bbox = BBox(bbox=[-5.7585989, 37.3886755, -5.7565442, 37.3910112], crs=CRS.WGS84)
geometry = Geometry(geometry={"coordinates":[[[-5.7580946,37.3905082],[-5.7579981,37.3903292],[-5.7585989,37.3902355],[-5.7585453,37.3893489],[-5.7583629,37.3886755],[-5.7573811,37.3887778],[-5.7565442,37.3910112],[-5.7580946,37.3905082]]],"type":"Polygon"}, crs=CRS.WGS84)

request = SentinelHubRequest(
    data_folder=nombreCarpeta,
    evalscript=evalscript,
    input_data=[
    SentinelHubRequest.input_data(
        data_collection=DataCollection.define_byoc('---------'),          
        time_interval=('2022-07-10', '2022-08-10'),          
    ),
],
    responses=[
        SentinelHubRequest.output_response('default', MimeType.JPG),
    ],
    bbox=bbox,
    geometry=geometry,
    size=[512, 512],
    config=config
)
response = request.get_data()
return request

request=buscarImg(562218, 5174019, 564201, 5172501, ‘2021-08-20’, ‘2021-08-20’,‘trueColor’, ‘trueColor’)

descargarImg(request)

print(request)