Examples for PlanetScope

To request data using any of the request below, you will need to replace the string <your access token> with your Sentinel Hub access token. Sentinel Hub access token can be obtained as described in the Authentication chapter. It will look something like this:

ayJhbGciOiJSUzI1NiJ9.ayJzdWIiOiI0MmYwODZjCy1kMzI3LTRlOTMtYWMxNS00ODAwOGFiZjI0YjIiLCJhdWQiOiJlY2I1MGM1Zi1i
MWM1LTQ3ZTgtYWE4NC0zZTU4NzJlM2I2MTEiLCJqdGkiOiI5MzYxMWE4ODEyNTM4Y2M0MmU0NDJjYjUyMTY0YmJlNyIsImV4cCI6MTU1N
TQyMzk3MiwibmFtZSI6ImFuamEudnJlY2tvQHNpbmVyZ2lzZS5jb20iLCJlbWFpbCI6ImFuamEudnJlY2tvQHNpbmVyZ2lzZS5jb20iLC
JzaWQiOiIzZjVjZDVkNS04MjRiLTQ3ZjYtODgwNy0wNDMyNWY4ODQxZmQifQ.U7FPOy_2jlEOFxXSjyN5KEdBROna3-Dyec0feShIbUOY
1p9lEXdNaMmR5euiINi2RXDayX9Kr47CuSTsvq1zHFvZs1YgkFr1iH6kDuX-t_-wfWpqu5oPjoPVKZ4Rj0Ms_dxAUTQFTXR0rlbLuO-KS
gnaeLVb5iiv_qY3Ctq2XKdIRcFRQLFziFcP4yZJl-NZMlwzsiiwjakcpYpI5jSYAdU2hpZLHRzceseeZt5YfZOe5Px1kZXro9Nd0L2GPC
-qzOXw_V1saMGFa2ov8qV6Dvk92iv2SDDdGhOdII_JOf8XkK4E3g2z0EEFdWhG9F4Iky4ukNsqBPgE8LRb31s0hg

A Postman collection with the examples can be downloaded here.

When your PlanetScope data is imported into Sentinel Hub using our Third Party Data Import API, you will receive the collection ID, with which you need to replace the collection ID 322d074f-eb62-4cbc-8776-8aa32cb84ea6 used in the examples in "type": "byoc-322d074f-eb62-4cbc-8776-8aa32cb84ea6". You will also need to adjust the values of bounds and timeRange parameters, so that they correspond to your data.

True Color

The following example of PlanetScope data returns a true color image. The bands are divided by 10000 to bring the 16-bit digital numbers to reflectance values and multiplied by 2.5 to increase the brightness.

curl -X POST \
https://services.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/EPSG/0/32633"
},
"bbox": [562218,5174019,564201,5172501]
},
"data": [
{
"type": "byoc-322d074f-eb62-4cbc-8776-8aa32cb84ea6",
"dataFilter": {
"timeRange": {
"from": "2019-04-27T00:00:00Z",
"to": "2019-04-28T00:00:00Z"
}
}
}
]
},
"output": {
"width": 512,
"height": 512
}
}' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: [{"bands": ["B1", "B2", "B3"]}],
output: { bands: 3}
}
}
function evaluatePixel(sample) {
return [2.5 * sample.B3 / 10000,
2.5 * sample.B2 / 10000,
2.5 * sample.B1 / 10000]
}'

NDVI visualized using valueInterpolate function

The following example of PlanetScope data returns a visualized NDVI image, using red and NIR bands.

curl -X POST \
https://services.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/EPSG/0/32633"
},
"bbox": [562218,5174019,564201,5172501]
},
"data": [
{
"type": "byoc-322d074f-eb62-4cbc-8776-8aa32cb84ea6",
"dataFilter": {
"timeRange": {
"from": "2019-04-27T00:00:00Z",
"to": "2019-04-28T00:00:00Z"
}
}
}
]
},
"output": {
"width": 512,
"height": 512
}
}' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: ["B3", "B4", "dataMask"],
output: { bands: 4}
}
}
function evaluatePixel(sample) {
var NDVI = index(sample.B4 , sample.B3)
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],
])
}'

False Color, exact band values using a floating point GeoTIFF

In this example we returned a false color composite with NIR, red and green bands in a TIFF format. We have specified sampleType to be FLOAT32, which will return reflectance values, that we prepared by dividing the bands by 10000.

curl -X POST \
https://services.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/EPSG/0/32633"
},
"bbox": [562218,5174019,564201,5172501]
},
"data": [
{
"type": "byoc-322d074f-eb62-4cbc-8776-8aa32cb84ea6",
"dataFilter": {
"timeRange": {
"from": "2019-04-27T00:00:00Z",
"to": "2019-04-28T00:00:00Z"
}
}
}
]
},
"output": {
"width": 512,
"height": 512,
"responses": [
{
"identifier": "default",
"format": {
"type": "image/tiff"
}
}
]
}
}' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: [{
bands: ["B4", "B3", "B2"]
}],
output: {
bands: 3,
sampleType: "FLOAT32"
}
}
}
function evaluatePixel(sample) {
return [sample.B4 / 10000,
sample.B3 / 10000,
sample.B2 / 10000]
}'