### Install Specific SDK Version
Source: https://docs.up42.com/sdk/installation
Install a specific version of the SDK and import the library.
```shell
pip install up42-py==3.0.0 # The version you want to install
import up42
```
--------------------------------
### Install UP42 SDK
Source: https://docs.up42.com/sdk/installation
Use these commands to install the UP42 Python SDK package using either pip or conda.
```shell
pip install up42-py
```
```shell
conda install -c conda-forge up42-py
```
--------------------------------
### CQL2 Filter Examples
Source: https://docs.up42.com/developers/api-stac
Examples demonstrating how to construct CQL2 filters for various search criteria.
```APIDOC
## CQL2 Filter Examples
### Cloud Cover Less Than 20%
```json
{
"filter": {
"op": "<",
"args": [
{
"property": "eo:cloud_cover"
},
20.0
]
}
}
```
### Tags Contain Specific Values
```json
{
"filter": {
"op": "a_contains",
"args": [
{
"property": "tags"
},
["optical", "aerial"]
]
}
}
```
### Tags Overlap Specific Values
```json
{
"filter": {
"op": "a_overlaps",
"args": [
{
"property": "tags"
},
["optical", "aerial"]
]
}
}
```
### Asset ID Equals Specific Value
```json
{
"filter": {
"op": "=",
"args": [
{
"property": "asset_id"
},
"b9fc2b75-f9de-46dd-a21b-320381bbb62d"
]
}
}
```
### Data Product ID Not Equals Specific Value
```json
{
"filter": {
"op": "!=",
"args": [
{
"property": "data_product_id"
},
"b0e4a80e-6a54-486c-ac0c-44497b602545"
]
}
}
```
### Created Before Timestamp
```json
{
"filter": {
"op": "<",
"args": [
{
"property": "created"
},
{
"timestamp": "2023-06-27T00:00:00.000Z"
}
]
}
}
```
### Cloud Cover Greater Than 20%
```json
{
"filter": {
"op": ">",
"args": [
{
"property": "eo:cloud_cover"
},
20.0
]
}
}
```
### Datetime Less Than or Equal To Timestamp
```json
{
"filter": {
"op": "<=",
"args": [
{
"property": "datetime"
},
{
"timestamp": "2023-06-27T00:00:00.000Z"
}
]
}
}
```
### Ground Sample Distance Greater Than or Equal To Value
```json
{
"filter": {
"op": ">=",
"args": [
{
"property": "gsd"
},
0.57
]
}
}
```
### Tags Is Null
```json
{
"filter": {
"op": "isNull",
"args": {
"property": "tags"
}
}
}
```
### Combined Filter (AND)
```json
{
"filter": {
"op": "and",
"args": [
{
"op": "<=",
"args": [
{
"property": "gsd"
},
0.7
]
},
{
"op": "<=",
"args": [
{
"property": "eo:cloud_cover"
},
20.0
]
}
]
}
}
```
### Combined Filter (OR)
```json
{
"filter": {
"op": "or",
"args": [
{
"op": "=",
"args": [
{
"property": "constellation"
},
"PNEO"
]
},
{
"op": "=",
"args": [
{
"property": "collection_name"
},
"pneo-tasking"
]
}
]
}
}
```
### Combined Filter (NOT)
```json
{
"filter": {
"op": "not",
"args": [
{
"op": "=",
"args": [
{
"property": "constellation"
},
"PNEO"
]
}
]
}
}
```
```
--------------------------------
### Check installed UP42 SDK version
Source: https://docs.up42.com/sdk/release-notes
Use these commands to verify the currently installed version of the UP42 Python SDK.
```bash
pip show up42-py
```
```bash
conda search up42-py
```
--------------------------------
### KML Point Example
Source: https://docs.up42.com/data/formats
Example of a KML file defining a single point with coordinates.
```xml
-73.98716020201383,40.73106717134863
```
--------------------------------
### Order Status and SubStatus Example
Source: https://docs.up42.com/developers/api-tasking
This JSON snippet shows an example of an order's status and subStatus. The `status` is the primary indicator, while `subStatus` provides further clarification, such as waiting for a feasibility study.
```json
{
"displayName": "Pléiades Neo over North America",
// Other parameters
"orderDetails": {
"subStatus": "FEASIBILITY_WAITING_UPLOAD"
// Other parameters
},
"status": "CREATED"
}
```
--------------------------------
### KML Multiple Points Example
Source: https://docs.up42.com/data/formats
Example of a KML file defining multiple points.
```xml
-73.98716020201383,40.73106717134863
-71.05828675347368,42.360262258503866
```
--------------------------------
### Download and Preview Quicklooks
Source: https://docs.up42.com/sdk/quick-start
Download a preview image for a selected scene and display it within a notebook environment.
```python
1
import pathlib
2
from IPython.display import Image, display
3
4
# 1. Select a scene
5
first_scene = scenes[0] # Get the first scene from your results
6
7
# 2. Create a directory to save the image
8
output_directory = pathlib.Path("downloaded_images")
9
output_directory.mkdir(exist_ok=True)
10
11
# 3. Download the quicklook
12
downloaded_file_path = first_scene.quicklook.download(output_directory)
13
print(f"Quicklook downloaded to: {downloaded_file_path}")
14
15
# 4. Display the downloaded image
16
print("\nQuicklook:")
17
display(Image(filename=downloaded_file_path, width=600))
```
--------------------------------
### Initialize STAC client
Source: https://docs.up42.com/sdk/sdk-data-management
Establishes a connection to the STAC client using the UP42 SDK.
```python
UP42_client = up42.stac_client()
```
--------------------------------
### Instantiate and Place a BatchOrderTemplate
Source: https://docs.up42.com/sdk/sdk-order-template
Create a batch order template with specific product parameters and submit the order.
```python
order_template = up42.BatchOrderTemplate(
data_product_id="c3de9ed8-f6e5-4bb5-a157-f6430ba756da",
display_name="Sentinel-2 over Berlin",
features=features,
params={
"id": "S2B_T32UQD_20250520T102551_L2A"
},
tags=["sentinel-berlin"]
)
# Submit the order
order_template.place
```
--------------------------------
### Get Processing Jobs
Source: https://docs.up42.com/developers/api-processing
Retrieve information about processing jobs. You can get all jobs or a specific job using its ID.
```APIDOC
## GET /jobs
### Description
Retrieves a list of all processing jobs.
### Method
GET
### Endpoint
/jobs
### Query Parameters
- **status** (string) - Optional - Filters jobs by their status.
### Response
#### Success Response (200)
- **jobs** (array) - A list of job objects.
- **job_id** (string) - The unique identifier for the job.
- **status** (string) - The current status of the job (e.g., `created`, `running`, `successful`).
#### Response Example
{
"jobs": [
{
"job_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"status": "successful"
}
]
}
## GET /jobs/{job_id}
### Description
Retrieves information about a specific processing job using its ID.
### Method
GET
### Endpoint
/jobs/{job_id}
### Parameters
#### Path Parameters
- **job_id** (string) - Required - The ID of the job to retrieve.
### Response
#### Success Response (200)
- **job_id** (string) - The unique identifier for the job.
- **status** (string) - The current status of the job.
#### Response Example
{
"job_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"status": "successful"
}
```
--------------------------------
### Search for Scenes using a Host Provider
Source: https://docs.up42.com/sdk/sdk-glossary
Demonstrates how to fetch archive collections, identify a host provider, define a search geometry, and perform a scene search with specific filters.
```python
import geojson
from itertools import islice
# Select the host
host = "oneatlas"
# Fetch catalog collections
archive_collections = up42.ProductGlossary.get_collections(
collection_type = up42.CollectionType.ARCHIVE,
sort_by = up42.CollectionSorting.name.asc,
)
# Find the provider matching the selected host name that's marked as a host
host_provider = next(
(
p
for c in archive_collections
for p in c.providers
if p.name == host and getattr(p, "is_host", False)
),
None,
)
# Define search geometry
geometry = {
"type": "Polygon",
"coordinates": [
[
[13.369713, 52.452327],
[13.369713, 52.470760],
[13.339159, 52.470760],
[13.339159, 52.452327],
[13.369713, 52.452327],
]
],
}
# Wrap the geometry into a GeoJSON FeatureCollection
features = geojson.FeatureCollection(features=[geojson.Feature(geometry=geometry)])
# Search for scenes using the host
scenes = host_provider.search(
collections=["SPOT", "phr"],
intersects=geometry,
start_date="2022-06-01",
end_date="2022-12-31",
query={"cloudCoverage": {"LT": 20}},
)
# Define output
for scene in islice(scenes, 0, 5): # Print first 5 results
print(f"- Scene ID: {scene.id}")
print(f" Bounding box: {scene.bbox}")
print(f" Geometry: {scene.geometry}")
print(f" Acquisition date and time: {scene.datetime}")
print(f" Acquisition start: {scene.start_datetime}")
print(f" Acquisition end: {scene.end_datetime}")
print(f" Constellation: {scene.constellation}")
print(f" Collection: {scene.collection}")
print(f" Cloud coverage: {scene.cloud_coverage}%")
print(f" Resolution: {scene.resolution} m")
print(f" Delivery time: {scene.delivery_time}")
print(f" Producer: {scene.producer}")
print(f" Quicklook: {scene.quicklook}\n")
```
--------------------------------
### Download an Image File
Source: https://docs.up42.com/sdk/sdk-utils
Instantiate an ImageFile object with a URL and filename, then download it to a specified directory. Ensure the output directory exists.
```python
import pathlib
# Select a URL
url = "https://storage.googleapis.com/user-storage-interstellar-prod/assets/a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Define a directory to store the downloaded image
output_directory = pathlib.Path("downloaded_images")
output_directory.mkdir(exist_ok=True)
# Instantiate the file
image_file = up42.utils.ImageFile(
url=url,
file_name="my_mage_name" # This will be used as the filename
)
# Download to the desired output directory
downloaded_file_path = image_file.download(output_directory=output_directory)
print(f"\nDownload finished.")
print(f"File was saved to: {downloaded_file_path}")
```
--------------------------------
### Retrieve EULA Metadata
Source: https://docs.up42.com/developers/api-eulas
Example response containing EULA metadata and the current document URL.
```json
1
{
2
"id": "4136a5db-3753-42ea-87f5-61579e63cf41",
3
"currentDocumentId": "79a45885-ec78-4158-ae7e-0460e480d44a",
4
"currentDocumentUrl": "https://storage.googleapis.com/<...>/version/1.pdf",
5
"currentDocumentCreatedAt": "2024-01-17T14:18:06.968272Z",
6
"currentDocumentValidFrom": "2024-01-17T00:00:00Z",
7
"currentDocumentFilename": "1.pdf",
8
"title": "Pléiades Analytic",
9
"description": "EULA for Pléiades Analytic",
10
"isAccepted": true,
11
"acceptedAt": "2024-01-19T15:10:16.263039Z",
12
"acceptedById": "68567134-27ad-7bd7-4b65-d61adb11fc78"
13
}
```
--------------------------------
### GeoJSON FeatureCollection Point Example
Source: https://docs.up42.com/data/formats
Example of a GeoJSON FeatureCollection containing a Point feature. Ensure your GeoJSON is structured as a FeatureCollection object.
```json
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [...]
}
}
]
}
```
--------------------------------
### GeoJSON FeatureCollection Polygon Example
Source: https://docs.up42.com/data/formats
Example of a GeoJSON FeatureCollection containing a Polygon feature. Ensure your GeoJSON is structured as a FeatureCollection object.
```json
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [...]
}
}
]
}
```
--------------------------------
### SDK Overview
Source: https://docs.up42.com/sdk/geometry
Provides a general overview of the UP42 Python SDK.
```APIDOC
## SDK Overview
The overview of UP42's Python SDK.
```
--------------------------------
### KML Multiple Polygons Example
Source: https://docs.up42.com/data/formats
Example of a KML file defining multiple polygons. KML supports Z-values but they are ignored by the platform.
```xml
-0.23813040507974392,51.468798304729745
-0.04103438196207776,51.468798304729745
-0.04103438196207776,51.54859446205262
-0.23813040507974392,51.54859446205262
-0.23813040507974392,51.468798304729745
-2.007448902677595,52.535413959131574
-2.007448902677595,52.4032156024264
-1.7842843091614498,52.4032156024264
-1.7842843091614498,52.535413959131574
-2.007448902677595,52.535413959131574
```
--------------------------------
### KML Polygon Example
Source: https://docs.up42.com/data/formats
Example of a KML file defining a single polygon with outer boundary coordinates. KML supports Z-values but they are ignored by the platform.
```xml
-77.05788457660967,38.87253259892824
-77.05465973756702,38.87291016281703
-77.0531553685479,38.87053267794386
-77.05552622493516,38.868757801256
-77.05844056290393,38.86996206506943
-77.05788457660967,38.87253259892824
```
--------------------------------
### Fetch Tasking and Archive Collections Separately
Source: https://docs.up42.com/sdk/sdk-glossary
Demonstrates fetching tasking and archive collections independently using `ProductGlossary.get_collections`. This snippet focuses on the retrieval part, with subsequent code handling the output.
```python
# Fetch collections
tasking_collections = up42.ProductGlossary.get_collections(
collection_type = up42.CollectionType.TASKING,
sort_by = up42.CollectionSorting.name.asc,
)
archive_collections = up42.ProductGlossary.get_collections(
collection_type = up42.CollectionType.ARCHIVE,
sort_by = up42.CollectionSorting.name.asc,
)
# Define output
print(f"Tasking collections")
for collection in tasking_collections:
print(f" {collection.title}: {collection.name}")
print(f" {collection.description}\n")
print(f"Catalog collections")
for collection in archive_collections:
print(f" {collection.title}: {collection.name}")
print(f" {collection.description}\n")
```
```python
# Fetch collections
tasking_collections = up42.ProductGlossary.get_collections(
collection_type = up42.CollectionType.TASKING,
sort_by = up42.CollectionSorting.name.asc,
)
archive_collections = up42.ProductGlossary.get_collections(
collection_type = up42.CollectionType.ARCHIVE,
sort_by = up42.CollectionSorting.name.asc,
)
```
--------------------------------
### GET /get_collections
Source: https://docs.up42.com/sdk/sdk-data-management
Retrieves all STAC collections available in the storage.
```APIDOC
## GET /get_collections
### Description
Retrieves all STAC collections. Returns an iterator of Collection objects.
### Method
GET
### Response
#### Success Response (200)
- **collections** (Iterator[Collection]) - An iterator containing STAC collection objects.
```
--------------------------------
### Instantiate BatchOrderTemplate
Source: https://docs.up42.com/sdk/sdk-order-template
This snippet demonstrates how to instantiate a BatchOrderTemplate with a data product ID, display name, features, parameters, and tags.
```APIDOC
## Instantiate a BatchOrderTemplate with the given parameters
```python
order_template = up42.BatchOrderTemplate(
data_product_id="c3de9ed8-f6e5-4bb5-a157-f6430ba756da",
display_name="Sentinel-2 over Berlin",
features=features,
params={
"id": "S2B_T32UQD_20250520T102551_L2A"
},
tags=["sentinel-berlin"]
)
```
## Submit the order
```python
order_template.place
```
```
--------------------------------
### POST /process
Source: https://docs.up42.com/processing/detection-buildings-spacept
Initiates the building detection process for a given input item.
```APIDOC
## POST /process
### Description
This endpoint triggers the building detection algorithm. It requires the title for the output and the absolute API path to the input data item.
### Method
POST
### Endpoint
/process
### Parameters
#### Request Body
- **inputs** (object) - Required - Contains input details for the processing job.
- **inputs.title** (string) - Required - The title of the output data item.
- **inputs.item** (string) - Required - The absolute API path to the input data item.
### Request Example
```json
{
"inputs": {
"title": "Processing imagery over Berlin",
"item": "https://api.up42.com/v2/assets/stac/collections/21c0b14e-3434-4675-98d1-f225507ded99/items/23e4567-e89b-12d3-a456-426614174000"
}
}
```
### Response
#### Success Response (200)
- **id** (string) - The unique identifier for the processing job.
- **status** (string) - The current status of the processing job.
#### Response Example
```json
{
"id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"status": "processing"
}
```
```
--------------------------------
### GET /orders
Source: https://docs.up42.com/sdk/sdk-order
Retrieves all orders with optional filtering capabilities.
```APIDOC
## GET /orders
### Description
Retrieves all orders, with optional filtering by workspace, type, status, sub-status, name, or tags.
### Parameters
#### Query Parameters
- **workspace_id** (str) - Optional - The workspace ID.
- **order_type** (OrderType) - Optional - The type of orders (TASKING or ARCHIVE).
- **status** (List[OrderStatus]) - Optional - List of order statuses.
- **sub_status** (List[OrderSubStatus]) - Optional - List of order sub-statuses.
- **display_name** (str) - Optional - Search term for order names.
- **tags** (List[str]) - Optional - List of tags to filter by.
- **sort_by** (SortingField) - Optional - Sorting method.
### Response
#### Success Response (200)
- **Iterator[Order]** - Returns an iterator of Order objects.
### Request Example
```python
orders = up42.Order.all(
order_type="TASKING",
status=["FULFILLED", "PLACED"],
sort_by=up42.OrderSorting.status.asc
)
```
```
--------------------------------
### Instantiate Pansharpening Template
Source: https://docs.up42.com/sdk/sdk-processing-templates
Creates a pansharpening job template, optionally specifying grey weights for multispectral bands. Requires at least 3 bands if weights are manually defined.
```python
from up42 import processing_templates
# Select an item
stac_item_id = "68567134-27ad-7bd7-4b65-d61adb11fc78"
# Get the item from the STAC client
UP42_client = up42.stac_client()
stac_item = next(UP42_client.get_items(stac_item_id))
# Instantiate a Pansharpening template with grey weights
job_template = processing_templates.Pansharpening(
title="Pansharpen item",
item=stac_item,
grey_weights=[
processing_templates.GreyWeight(band="red", weight=0.04),
processing_templates.GreyWeight(band="blue", weight=0.9),
processing_templates.GreyWeight(band="green", weight=0.2),
],
)
```
--------------------------------
### GET /providers
Source: https://docs.up42.com/developers/api-glossary
Retrieves a list of all geospatial data providers.
```APIDOC
## GET /providers
### Description
Retrieves a list of all organizations that offer geospatial data (producers or hosts).
### Method
GET
### Endpoint
/providers
```
--------------------------------
### GET /geometries
Source: https://docs.up42.com/developers/api-geometries
Retrieves a list of all geometries saved in the library.
```APIDOC
## GET /geometries
### Description
Returns a list of all geometries available in the library.
### Method
GET
### Endpoint
/geometries
```
--------------------------------
### Generate Access Token Request
Source: https://docs.up42.com/developers/authentication
HTTP and cURL examples to request an access token from the authentication server.
```HTTP
POST /realms/public/protocol/openid-connect/token HTTP/1.1
Host: auth.up42.com
Content-Type: application/x-www-form-urlencoded
username=&password=&grant_type=password&client_id=up42-api
```
```Shell
curl --location --request POST 'https://auth.up42.com/realms/public/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=' \
--data-urlencode 'password=' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id=up42-api'
```
--------------------------------
### GET /data-products
Source: https://docs.up42.com/developers/api-glossary
Retrieves a list of all available data products.
```APIDOC
## GET /data-products
### Description
Retrieves a list of all data products, which are imagery types with specific processing levels and formats.
### Method
GET
### Endpoint
/data-products
```
--------------------------------
### Authenticate using a configuration file
Source: https://docs.up42.com/sdk/authentication
Use the authenticate method to load credentials from a JSON file. Optional region parameters can be specified.
```python
import up42
up42.authenticate(cfg_file="credentials.json")
```
```python
import up42
up42.authenticate(cfg_file="credentials.json", region="sa")
```
--------------------------------
### GET /collections
Source: https://docs.up42.com/developers/api-glossary
Retrieves a list of all available geospatial collections.
```APIDOC
## GET /collections
### Description
Retrieves a list of all geospatial collections available for ordering.
### Method
GET
### Endpoint
/collections
```
--------------------------------
### POST /process
Source: https://docs.up42.com/processing/detection-trees-spacept
Initiates the tree detection process. You need to provide the name ID `detection-trees-spacept` for this process.
```APIDOC
## POST /process
### Description
Initiates the tree detection process using the `detection-trees-spacept` algorithm.
### Method
POST
### Endpoint
/process
### Parameters
#### Request Body
- **inputs** (object) - Required - Contains input parameters for the process.
- **title** (string) - Required - The title of the output data item.
- **item** (string) - Required - The absolute API path to the input data item.
### Request Example
```json
{
"inputs": {
"title": "Processing imagery over Berlin",
"item": "https://api.up42.com/v2/assets/stac/collections/21c0b14e-3434-4675-98d1-f225507ded99/items/23e4567-e89b-12d3-a456-426614174000"
}
}
```
### Response
#### Success Response (200)
- **id** (string) - The ID of the initiated process.
- **status** (string) - The current status of the process.
#### Response Example
```json
{
"id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"status": "queued"
}
```
```
--------------------------------
### Instantiate a BatchOrderTemplate
Source: https://docs.up42.com/sdk/sdk-order-template
Creates a template instance for batch orders using a data product ID, display name, GeoJSON features, parameters, and tags.
```python
1
import geojson
2
3
# Define order geometry
13 collapsed lines
4
geometry = {
5
"type": "Polygon",
6
"coordinates": [[
7
[13.369713, 52.452327],
8
[13.369713, 52.470760],
9
[13.339159, 52.470760],
10
[13.339159, 52.452327],
11
[13.369713, 52.452327]
12
]]
13
}
14
15
# Wrap the geometry into a GeoJSON FeatureCollection
16
features = geojson.FeatureCollection(features=[geojson.Feature(geometry=geometry)])
17
18
# Instantiate a BatchOrderTemplate with the given parameters
19
order_template = up42.BatchOrderTemplate(
20
data_product_id="c3de9ed8-f6e5-4bb5-a157-f6430ba756da",
21
display_name="Sentinel-2 over Berlin",
22
features=features,
23
params={
24
"id": "S2B_T32UQD_20250520T102551_L2A"
25
},
26
tags=["sentinel-berlin"]
27
)
```
--------------------------------
### GET /jobs
Source: https://docs.up42.com/sdk/sdk-processing
Retrieves a list of all jobs with optional filtering parameters.
```APIDOC
## GET /jobs
### Description
Retrieves all jobs, with optional filtering. Returns an iterator of Job objects.
### Parameters
#### Query Parameters
- **process_id** (Optional[List[str]]) - Optional - Process IDs to filter by.
- **workspace_id** (Optional[str]) - Optional - The workspace ID.
- **status** (Optional[List[JobStatus]]) - Optional - Job statuses to filter by.
- **min_duration** (Optional[int]) - Optional - Minimum duration in seconds.
- **max_duration** (Optional[int]) - Optional - Maximum duration in seconds.
- **sort_by** (Optional[utils.SortingField]) - Optional - Sorting method.
- **ids** (Optional[List[str]]) - Optional - List of specific job IDs to retrieve.
### Request Example
```python
jobs = up42.Job.all(max_duration=500, sort_by=up42.JobSorting.process_id)
```
```