Copy for LLM[View as Markdown](https://docs.planet.com/develop/apis/processing/examples/) # Processing API Examples This page provides examples for accessing Planet data collections using the Processing API. These examples demonstrate how to request imagery, calculate indices, and export data in various formats. note To use these examples, you need: * A valid access token (see [Authentication](https://docs.planet.com/develop/authentication.md)) * A data collection ID (obtained when you order or subscribe to data) * Data delivered to your data collection Replace `` with your actual collection ID in the format `byoc-`. ## Mosaicking All Planet data collections support all [mosaicking types](https://docs.planet.com/develop/evalscripts/functions.md#mosaicking): `SIMPLE`, `TILE`, and `ORBIT`. Use mosaicking to access multiple scenes within a time range or to control how overlapping tiles are combined. For more information, see: * [Mosaicking](https://docs.planet.com/develop/evalscripts/functions.md#mosaicking) * [Accessing BYOC Data](https://docs.planet.com/develop/apis/byoc.md#accessing-byoc-data) ## Analysis-Ready PlanetScope Examples Analysis-Ready PlanetScope (ARPS) provides harmonized, cloud-masked surface reflectance data at 3 m resolution. The following examples demonstrate common use cases. For information about available bands and data types, see [Analysis-Ready PlanetScope](https://docs.planet.com/data/imagery/arps.md#available-bands-and-data). ### True Color This example returns a true color image at full 3 m resolution. The bands are divided by 10000 to convert digital numbers to reflectance values and multiplied by 2.5 to increase brightness. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/png" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"red\", \"green\", \"blue\"],\n output: { bands: 3 }\n };\n}\n\nfunction evaluatePixel(sample) {\n return [2.5 * sample.red / 10000, 2.5 * sample.green / 10000, 2.5 * sample.blue / 10000];\n}" } ``` ### False Color This example returns a false color composite using NIR, red, and green bands. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/png" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"nir\", \"red\", \"green\"],\n output: { bands: 3 }\n };\n}\n\nfunction evaluatePixel(sample) {\n return [2.5 * sample.nir / 10000, 2.5 * sample.red / 10000, 2.5 * sample.green / 10000];\n}" } ``` ### NDVI Visualization This example calculates the Normalized Difference Vegetation Index (NDVI) and visualizes it using the `valueInterpolate` function. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/png" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"red\", \"nir\"],\n output: { bands: 3 }\n };\n}\n\nfunction evaluatePixel(sample) {\n let ndvi = (sample.nir - sample.red) / (sample.nir + sample.red);\n return valueInterpolate(ndvi, [\n [-1, [0, 0, 0]],\n [0, [1, 0, 0]],\n [0.5, [1, 1, 0]],\n [1, [0, 1, 0]]\n ]);\n}" } ``` ### Export as GeoTIFF This example exports all ARPS bands as a GeoTIFF file with exact band values. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/tiff" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"blue\", \"green\", \"red\", \"nir\", \"cloud_mask\", \"scene_mask\"],\n output: {\n bands: 6,\n sampleType: \"INT16\"\n }\n };\n}\n\nfunction evaluatePixel(sample) {\n return [sample.blue, sample.green, sample.red, sample.nir, sample.cloud_mask, sample.scene_mask];\n}" } ``` ## PlanetScope Examples PlanetScope provides near-daily global coverage at 3 m resolution. Data can be ordered as 4-band or 8-band bundles with either top-of-atmosphere reflectance or surface reflectance. For information about available bands and product bundles, see [PlanetScope](https://docs.planet.com/data/imagery/planetscope.md). ### True Color (4-band) This example returns a true color image using 4-band PlanetScope data. The bands are divided by 10000 to convert digital numbers to reflectance values and multiplied by 2.5 to increase brightness. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/png" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"red\", \"green\", \"blue\"],\n output: { bands: 3 }\n };\n}\n\nfunction evaluatePixel(sample) {\n return [2.5 * sample.red / 10000, 2.5 * sample.green / 10000, 2.5 * sample.blue / 10000];\n}" } ``` ### False Color (8-band) This example returns a false color composite using 8-band PlanetScope data with NIR, red, and green bands. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/png" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"nir\", \"red\", \"green\"],\n output: { bands: 3 }\n };\n}\n\nfunction evaluatePixel(sample) {\n return [2.5 * sample.nir / 10000, 2.5 * sample.red / 10000, 2.5 * sample.green / 10000];\n}" } ``` ### NDVI Visualization This example calculates NDVI and visualizes it using color mapping. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/png" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"red\", \"nir\"],\n output: { bands: 3 }\n };\n}\n\nfunction evaluatePixel(sample) {\n let ndvi = (sample.nir - sample.red) / (sample.nir + sample.red);\n return valueInterpolate(ndvi, [\n [-1, [0, 0, 0]],\n [0, [1, 0, 0]],\n [0.5, [1, 1, 0]],\n [1, [0, 1, 0]]\n ]);\n}" } ``` ### Export 8-band as GeoTIFF This example exports all 8 bands from PlanetScope SuperDove imagery as a GeoTIFF. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/tiff" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"coastal_blue\", \"blue\", \"green_i\", \"green\", \"yellow\", \"red\", \"rededge\", \"nir\"],\n output: {\n bands: 8,\n sampleType: \"UINT16\"\n }\n };\n}\n\nfunction evaluatePixel(sample) {\n return [sample.coastal_blue, sample.blue, sample.green_i, sample.green, sample.yellow, sample.red, sample.rededge, sample.nir];\n}" } ``` ### Using Usable Data Mask (UDM2) This example demonstrates how to filter out clouds using the UDM2 cloud mask band. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/png" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"red\", \"green\", \"blue\", \"cloud\"],\n output: { bands: 3 }\n };\n}\n\nfunction evaluatePixel(sample) {\n // Return black for cloudy pixels\n if (sample.cloud === 1) {\n return [0, 0, 0];\n }\n return [2.5 * sample.red / 10000, 2.5 * sample.green / 10000, 2.5 * sample.blue / 10000];\n}" } ``` ## SkySat Examples SkySat provides sub-meter resolution imagery (approximately 50 cm) with both multispectral and panchromatic bands. Data is available as scenes or collects. For information about SkySat imagery products and asset types, see [SkySat](https://docs.planet.com/data/imagery/skysat.md). ### True Color This example returns a true color image from SkySat multispectral data. The bands are divided by 10000 to convert digital numbers to reflectance values and multiplied by 2.5 to increase brightness. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/png" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"red\", \"green\", \"blue\"],\n output: { bands: 3 }\n };\n}\n\nfunction evaluatePixel(sample) {\n return [2.5 * sample.red / 10000, 2.5 * sample.green / 10000, 2.5 * sample.blue / 10000];\n}" } ``` ### Panchromatic Image This example returns a panchromatic (grayscale) image with higher spatial resolution. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/png" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"pan\"],\n output: { bands: 1, sampleType: \"AUTO\" }\n };\n}\n\nfunction evaluatePixel(sample) {\n return [2.5 * sample.pan / 10000];\n}" } ``` ### NDVI Visualization This example calculates NDVI from SkySat multispectral data and visualizes it with color mapping. ``` { "input": { "bounds": { "bbox": [13.822, 45.85, 13.826, 45.854], "properties": { "crs": "http://www.opengis.net/def/crs/EPSG/0/4326" } }, "data": [ { "type": "byoc-", "dataFilter": { "timeRange": { "from": "2023-06-01T00:00:00Z", "to": "2023-06-30T23:59:59Z" } } } ] }, "output": { "width": 512, "height": 512, "responses": [ { "identifier": "default", "format": { "type": "image/png" } } ] }, "evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [\"red\", \"nir\"],\n output: { bands: 3 }\n };\n}\n\nfunction evaluatePixel(sample) {\n let ndvi = (sample.nir - sample.red) / (sample.nir + sample.red);\n return valueInterpolate(ndvi, [\n [-1, [0, 0, 0]],\n [0, [1, 0, 0]],\n [0.5, [1, 1, 0]],\n [1, [0, 1, 0]]\n ]);\n}" } ```