Get Started with the Python API
Prerequisites
An Earthscale account. Please reach out to [email protected] in case you do not have one.
Permissions to access the data you want to visualize. Please refer to the Set up data access section.
Install the Earthscale Package
To use the Python API, first install the earthscale
package:
uv add earthscale
We currently require a minimum Python version of 3.10 and try to keep dependencies minimal to avoid conflicts with your environments.
Authenticating
To use the Python client, you'll need to authenticate. There are two options:
1. Using environment variables
For accounts with a username and password, set the following environment variables:
export EARTHSCALE_EMAIL=<your-email>
export EARTHSCALE_PASSWORD=<your-password>
This is helpful for using Earthscale in automated pipelines. You can inject the credentials into your pipelines using a secret manager like Vault.
2. Login via Browser
If you use "Sign in with Google" to log into Earthscale, you can use the earthscale authenticate
CLI command or let the client handle authentication automatically.
Adding a GeoTIFF Dataset
from earthscale import EarthscaleClient
with EarthscaleClient() as client:
response = client.add_image_dataset(
name="Tanzania Landsat Sample",
url="gs://earthscale-public/samples/hls_tanzania.tif",
)
dataset = client.get_dataset(response.dataset_id)
dataset
You can use the URL returned by the dataset.dynamic_tile_server.tile_url
to integrate the tile server into your own application. Make sure you set the min and max zoom range as returned from this response in your map rendering library.
See Use Earthscale in Your Products on how to best configure and use suitable visualization parameters for these URLs.
Listing datasets
from earthscale import EarthscaleClient
with EarthscaleClient() as client:
response = client.list_datasets()
response
You can use the dataset id in the list response to query details of a dataset using get_dataset()
Last updated