Examples for MODIS

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 will look something like this:

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

and can be obtained as described in the Authentication chapter.

A Postman collection with examples can be downloaded here. Our Postman collections are deprecated and are not being updated since July 2022.

True Color

curl -X POST \
https://services-uswest2.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
},
"bbox": [
11.90105,
41.446844,
12.64972,
41.999815
]
},
"data": [{
"type": "modis",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
}
}
}]
},
"output": {
"width": 512,
"height": 512
}
}
' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: ["B01", "B03", "B04"],
output: {
bands: 3,
sampleType: "AUTO" // default value - scales the output values from [0,1] to [0,255].
}
}
}
function evaluatePixel(sample) {
return [2.5 * sample.B01, 2.5 * sample.B04, 2.5 * sample.B03]
}
'

True Color, resolution (EPSG 32633)

curl -X POST \
https://services-uswest2.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": [
408553.58,
5078145.48,
466081.02,
5126576.61
]
},
"data": [{
"type": "modis",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
}
}
}]
},
"output": {
"resx": 500,
"resy": 500
}
}
' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: ["B01", "B03", "B04"],
output: {
bands: 3
}
}
}
function evaluatePixel(sample) {
return [2.5 * sample.B01, 2.5 * sample.B04, 2.5 * sample.B03]
}
'

True Color, multi-band GeoTIff

curl -X POST \
https://services-uswest2.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-H 'Accept: image/tiff' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
},
"bbox": [
11.90105,
41.446844,
12.64972,
41.999815
]
},
"data": [{
"type": "modis",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
}
}
}]
},
"output": {
"width": 512,
"height": 512
}
}
' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: ["B01", "B03", "B04"],
output: {
bands: 3,
sampleType: "AUTO" // default value - scales the output values from [0,1] to [0,255].
}
}
}
function evaluatePixel(sample) {
return [2.5 * sample.B01, 2.5 * sample.B04, 2.5 * sample.B03]
}
'

True Color, mosaicking with leastRecent

curl -X POST \
https://services-uswest2.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
},
"bbox": [
11.90105,
41.446844,
12.64972,
41.999815
]
},
"data": [{
"type": "modis",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
},
"mosaickingOrder": "leastRecent"
}
}]
},
"output": {
"width": 512,
"height": 512,
"responses": [{
"identifier": "default",
"format": {
"type": "image/png"
}
}]
}
}
' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: ["B01", "B03", "B04"],
output: {
bands: 3
}
}
}
function evaluatePixel(sample) {
return [2.5 * sample.B01, 2.5 * sample.B04, 2.5 * sample.B03]
}
'

True color and metadata (multi-part response GeoTIFF and json)

curl -X POST \
https://services-uswest2.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-H 'accept: application/tar' \
-F 'request={
"input": {
"bounds": {
"bbox": [
11.90105,
41.446844,
12.64972,
41.999815
]
},
"data": [{
"type": "modis",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
}
}
}]
},
"output": {
"width": 512,
"height": 512,
"responses": [{
"identifier": "default",
"format": {
"type": "image/tiff"
}
},
{
"identifier": "userdata",
"format": {
"type": "application/json"
}
}
]
}
}
' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: ["B01", "B03", "B04"],
mosaicking: Mosaicking.ORBIT,
output: {
id: "default",
bands: 3
}
}
}
function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
outputMetadata.userData = {
"scenes": scenes.orbits
}
}
function evaluatePixel(samples) {
return [2.5 * samples[0].B01, 2.5 * samples[0].B04, 2.5 * samples[0].B03]
}
'

True color multi-part-reponse (different formats and SampleType)

curl -X POST \
https://services-uswest2.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-H 'Accept: application/tar' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
},
"bbox": [
11.90105,
41.446844,
12.64972,
41.999815
]
},
"data": [{
"type": "modis",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
}
}
}]
},
"output": {
"width": 512,
"height": 512,
"responses": [{
"identifier": "true_color",
"format": {
"type": "image/jpeg"
}
},
{
"identifier": "true_color_8bit",
"format": {
"type": "image/png"
}
},
{
"identifier": "true_color_16bit",
"format": {
"type": "image/tiff"
}
},
{
"identifier": "true_color_32float",
"format": {
"type": "image/tiff"
}
}
]
}
}
' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: [{
bands: ["B04", "B03", "B01"],
units: "REFLECTANCE" // default units
}],
output: [{
id: "true_color",
bands: 3,
sampleType: "AUTO" // default - scales the output values from input values [0,1] to [0,255].
},
{
id: "true_color_8bit",
bands: 3,
sampleType: "UINT8"
},
{
id: "true_color_16bit",
bands: 3,
sampleType: "UINT16" //floating point values are automatically rounded to the nearest integer by the service.
},
{
id: "true_color_32float",
bands: 3,
sampleType: "FLOAT32"
}
]
}
}
function evaluatePixel(sample) {
return {
// output band values are scaled from [0,1] to [0,255]. Multiply by 2.5 to increase brightness
true_color: [2.5 * sample.B01, 2.5 * sample.B04, 2.5 * sample.B03],
// Multiply input reflectance values by 255 to stretch them to [0, 255] unsigned 8 bit range.
true_color_8bit: [sample.B01 * 255, sample.B04 * 255, sample.B03 * 255],
// Multiply input reflectance values by 65535 to stretch them to [0, 65535] unsigned 16 bit range.
true_color_16bit: [sample.B01 * 65535, sample.B04 * 65535, sample.B03 * 65535],
// Reflectance values
true_color_32float: [sample.B01, sample.B04, sample.B03],
}
}
'

NDVI as jpeg image with bounds given as polygon

curl -X POST \
https://services-uswest2.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
12.306089,
41.756971
],
[
12.470843,
41.666757
],
[
12.580678,
41.703678
],
[
12.64972,
41.818408
],
[
12.597154,
41.957448
],
[
12.495556,
41.999815
],
[
12.358261,
41.999815
],
[
12.284122,
41.932933
],
[
12.256663,
41.863425
],
[
12.306089,
41.756971
]
]
]
}
},
"data": [{
"type": "modis",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
}
}
}]
},
"output": {
"width": 512,
"height": 512,
"responses": [{
"identifier": "default",
"format": {
"type": "image/jpeg",
"quality": 80
}
}]
}
}
' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: [{
bands: ["B01", "B02"],
}],
output: {
id: "default",
bands: 3,
}
}
}
function evaluatePixel(sample) {
let ndvi = (sample.B02 - sample.B01) / (sample.B02 + sample.B01)
if (ndvi < -0.5) return [0.05, 0.05, 0.05]
else if (ndvi < -0.2) return [0.75, 0.75, 0.75]
else if (ndvi < -0.1) return [0.86, 0.86, 0.86]
else if (ndvi < 0) return [0.92, 0.92, 0.92]
else if (ndvi < 0.025) return [1, 0.98, 0.8]
else if (ndvi < 0.05) return [0.93, 0.91, 0.71]
else if (ndvi < 0.075) return [0.87, 0.85, 0.61]
else if (ndvi < 0.1) return [0.8, 0.78, 0.51]
else if (ndvi < 0.125) return [0.74, 0.72, 0.42]
else if (ndvi < 0.15) return [0.69, 0.76, 0.38]
else if (ndvi < 0.175) return [0.64, 0.8, 0.35]
else if (ndvi < 0.2) return [0.57, 0.75, 0.32]
else if (ndvi < 0.25) return [0.5, 0.7, 0.28]
else if (ndvi < 0.3) return [0.44, 0.64, 0.25]
else if (ndvi < 0.35) return [0.38, 0.59, 0.21]
else if (ndvi < 0.4) return [0.31, 0.54, 0.18]
else if (ndvi < 0.45) return [0.25, 0.49, 0.14]
else if (ndvi < 0.5) return [0.19, 0.43, 0.11]
else if (ndvi < 0.55) return [0.13, 0.38, 0.07]
else if (ndvi < 0.6) return [0.06, 0.33, 0.04]
else return [0, 0.27, 0]
}
'

Exact NDVI values using a floating point GeoTIFF

curl -X POST \
https://services-uswest2.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
12.306089,
41.756971
],
[
12.470843,
41.666757
],
[
12.580678,
41.703678
],
[
12.64972,
41.818408
],
[
12.597154,
41.957448
],
[
12.495556,
41.999815
],
[
12.358261,
41.999815
],
[
12.284122,
41.932933
],
[
12.256663,
41.863425
],
[
12.306089,
41.756971
]
]
]
}
},
"data": [{
"type": "modis",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
}
}
}]
},
"output": {
"width": 512,
"height": 512,
"responses": [{
"identifier": "default",
"format": {
"type": "image/tiff"
}
}]
}
}
' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: [{
bands: ["B01", "B02"]
}],
output: {
id: "default",
bands: 1,
sampleType: SampleType.FLOAT32
}
}
}
function evaluatePixel(sample) {
let ndvi = (sample.B02 - sample.B01) / (sample.B02 + sample.B01)
return [ndvi]
}
'

NDVI image and value (multi-part response png and GeoTIFF)

curl -X POST \
https://services-uswest2.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-H 'Accept: application/tar' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
12.306089,
41.756971
],
[
12.470843,
41.666757
],
[
12.580678,
41.703678
],
[
12.64972,
41.818408
],
[
12.597154,
41.957448
],
[
12.495556,
41.999815
],
[
12.358261,
41.999815
],
[
12.284122,
41.932933
],
[
12.256663,
41.863425
],
[
12.306089,
41.756971
]
]
]
}
},
"data": [{
"type": "modis",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
}
}
}]
},
"output": {
"width": 512,
"height": 512,
"responses": [{
"identifier": "ndvi_image",
"format": {
"type": "image/png"
}
},
{
"identifier": "default",
"format": {
"type": "image/tiff"
}
}
]
}
}
' \
-F 'evalscript=//VERSION=3
function setup( ){
return{
input: [{
bands:["B01", "B02"],
}],
output: [{
id: "default",
bands: 1,
sampleType: SampleType.FLOAT32},
{
id: "ndvi_image",
bands: 3,
sampleType: SampleType.AUTO}
]
}
}
function evaluatePixel(sample) {
let ndvi = (sample.B02 - sample.B01) / (sample.B02 + sample.B01)
if (ndvi<-0.5) image = [0.05,0.05,0.05]
else if (ndvi<-0.2) image = [0.75,0.75,0.75]
else if (ndvi<-0.1) image = [0.86,0.86,0.86]
else if (ndvi<0) image = [0.92,0.92,0.92]
else if (ndvi<0.025) image = [1,0.98,0.8]
else if (ndvi<0.05) image = [0.93,0.91,0.71]
else if (ndvi<0.075) image = [0.87,0.85,0.61]
else if (ndvi<0.1) image = [0.8,0.78,0.51]
else if (ndvi<0.125) image = [0.74,0.72,0.42]
else if (ndvi<0.15) image = [0.69,0.76,0.38]
else if (ndvi<0.175) image = [0.64,0.8,0.35]
else if (ndvi<0.2) image = [0.57,0.75,0.32]
else if (ndvi<0.25) image = [0.5,0.7,0.28]
else if (ndvi<0.3) image = [0.44,0.64,0.25]
else if (ndvi<0.35) image = [0.38,0.59,0.21]
else if (ndvi<0.4) image = [0.31,0.54,0.18]
else if (ndvi<0.45) image = [0.25,0.49,0.14]
else if (ndvi<0.5) image = [0.19,0.43,0.11]
else if (ndvi<0.55) image = [0.13,0.38,0.07]
else if (ndvi<0.6) image = [0.06,0.33,0.04]
else image = [0,0.27,0]
return {
default: [ ndvi ],
ndvi_image: image
}
}'

All MODIS bands as GeoTIFF

curl -X POST \
https://services-uswest2.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
12.306089,
41.756971
],
[
12.470843,
41.666757
],
[
12.580678,
41.703678
],
[
12.64972,
41.818408
],
[
12.597154,
41.957448
],
[
12.495556,
41.999815
],
[
12.358261,
41.999815
],
[
12.284122,
41.932933
],
[
12.256663,
41.863425
],
[
12.306089,
41.756971
]
]
]
}
},
"data": [{
"type": "modis",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
}
}
}]
},
"output": {
"width": 512,
"height": 512,
"responses": [{
"identifier": "default",
"format": {
"type": "image/tiff"
}
}]
}
}
' \
-F 'evalscript=//VERSION=3
function setup() {
return {
input: [{
bands: ["B01", "B02", "B03", "B04", "B05", "B06", "B07", "dataMask"]
}],
output: {
id: "default",
bands: 8,
sampleType: SampleType.UINT16 //floating point values are automatically rounded to the nearest integer by the service.
}
}
}
function evaluatePixel(sample) {
// Return reflectance multiplied by 10000 as integers to save processing units. To obtain reflectance values, simply divide the resulting pixel values by 10000.
return [10000 * sample.B01, 10000 * sample.B02, 10000 * sample.B03, 10000 * sample.B04, 10000 * sample.B05, 10000 * sample.B06, 10000 * sample.B07, sample.dataMask]
}
'