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 906b545b-4305-4968-b245-2abcb0609bc1 used in the examples in "type": "byoc-906b545b-4305-4968-b245-2abcb0609bc1". You will also need to adjust the values of bounds and timeRange parameters, so that they correspond to your data.

Unless specified otherwise, the PSScene itemType with an 8-band productBundle was used in the examples below.

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-906b545b-4305-4968-b245-2abcb0609bc1",
"dataFilter": {
"timeRange": {
"from": "2021-08-20T00:00:00Z",
"to": "2021-08-20T23:59:59Z"
}
}
}
]
},
"output": {
"width": 512,
"height": 512
}
}' \
-F '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]
}'

True Color, PSScene4Band

If you have PSScene4Band PlanetScope data ingested and would like to add newer data into the same collection, you can order the legacy PSScene4Band itemType instead of the default PSScene. Doing so will ensure compatibility with older acquisitions. However, we recommend you start using PSScene, as PSScene4Band will be deprecated by Planet in January 2023. 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-203d3c7b-2088-4c16-adb7-65c9e26d8834",
"dataFilter": {
"timeRange": {
"from": "2019-04-27T00:00:00Z",
"to": "2019-04-27T23:59:59Z"
}
}
}
]
},
"output": {
"width": 512,
"height": 512,
"responses": [
{
"identifier": "default",
"format": {
"type": "image/png"
}
}
]
}
}' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: ["B1", "B2", "B3", "dataMask"],
output: { bands: 4}
}
}
function evaluatePixel(sample) {
return [2.5 * sample.B3 / 10000,
2.5 * sample.B2 / 10000,
2.5 * sample.B1 / 10000,
sample.dataMask]
}'

True Color, full 3 meter resolution

The following example of PlanetScope data returns a true color image in full 3 meter resolution. 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-906b545b-4305-4968-b245-2abcb0609bc1",
"dataFilter": {
"timeRange": {
"from": "2021-08-20T00:00:00Z",
"to": "2021-08-20T23:59:59Z"
}
}
}
]
},
"output": {
"resx": 3,
"resy": 3
}
}' \
-F '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]
}'

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-906b545b-4305-4968-b245-2abcb0609bc1",
"dataFilter": {
"timeRange": {
"from": "2021-08-20T00:00:00Z",
"to": "2021-08-20T23:59:59Z"
}
}
}
]
},
"output": {
"width": 512,
"height": 512,
"responses": [
{
"identifier": "default",
"format": {
"type": "image/png"
}
}
]
}
}' \
-F '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],
])
}'

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-906b545b-4305-4968-b245-2abcb0609bc1",
"dataFilter": {
"timeRange": {
"from": "2021-08-20T00:00:00Z",
"to": "2021-08-20T23:59:59Z"
}
}
}
]
},
"output": {
"width": 512,
"height": 512,
"responses": [
{
"identifier": "default",
"format": {
"type": "image/tiff"
}
}
]
}
}' \
-F '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]
}'

False Color, 4 band bundle

To access data acquired in 2017, we ordered a 4 band bundle (analytic_udm2 or analytic_sr_udm2), as 8-band bundles are not available for older dates. Note that we had to ingest 4-band data into a different collection, as different bundles are not compatible. The evalscript is the same for both bundles. The following example of PlanetScope data returns a false 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-f85cae37-0b95-4817-9b46-bd4138ca3038",
"dataFilter": {
"timeRange": {
"from": "2017-04-21T00:00:00Z",
"to": "2017-04-21T23:59:59Z"
}
}
}
]
},
"output": {
"width": 512,
"height": 512,
"responses": [
{
"identifier": "default",
"format": {
"type": "image/png"
}
}
]
}
}' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: ["NIR", "Red", "Green", "dataMask"],
output: { bands: 4}
}
}
function evaluatePixel(sample) {
return [2.5 * sample.NIR / 10000,
2.5 * sample.Red / 10000,
2.5 * sample.Green / 10000,
sample.dataMask]
}'