eo-bathymetry-functions
Automation of satellite-derived bathymetry generation with GSC Cloud Functions.
This repository contains code to create and export Satellite Derived Bathymetry images using
Google Earth Engine. The code consists of two Google Cloud Functions: one to create images and
export images to an ImageCollection in earthengine and one to export that ImageCollection as
tiles to cloud storage.
Python cloud functions in Cloud Functions are based on Flask APIs.
The infrastructure code (terraform) deploys all the infrastructure needed on google cloud. This includes some google cloud buckets, access management, some objects in the bucket and the cloud functions themselves, along with schedulers to query the functions.
Terraform
This contains terraform code to set-up google cloud platform resources that are used in this project. The state is stored in a cloud bucket that needs to be created manually.
To obtain credentials to use for local development, use:
gcloud auth application-default login --project bathymetry
You need to enable the service account with google earth engine here. You also need an app engine application for using the cloud scheduler.
When developing, use make get_tf_key to get your service account setup. Then you can
terraform plan -var-file workspaces/default.tfvars in the terraform folder.
Local Development
Install docker, pack cli, terraform, install gcloud and login to the bathymetry project as
described in the terraform section. 2 Cloud Functions are used.
To test calculating and exporting bathymetry, use: make local_deploy_sdb.
To test exporting the hillshaded tiles, use: make local_deploy_rgb.
These commands start a docker image in the terminal, which exposes the cloud function on port 8080.
Tools
The tools directory contain some scripts to do some common development tasks, like stopping tasks, checking task statuses, and more.
Deployment
make deploy runs terraform and deploys to cloud functions.
Adding schedulers
When adding a scheduler, add to the job_configs terraform variable in
./terraform/workspaces/defaults.tfvars, where the key is the name of the scheduler.
Limitations
Due to the current implementation, this api needs to wait a few times on the earthengine api. CloudFunctions times out at max 10 minutes. To create many tiles in one go (>100), please query this api multiple times with different parameters.
Example queries to the API
Query a small area and store the result in an asset.
{
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
4.726555204480136,
52.79894952106581
],
[
5.382988309948886,
53.2615577684405
],
[
5.226433134167636,
53.48931215536743
],
[
4.770500516980136,
53.41898585234949
],
[
4.270622587292636,
52.91018589685636
],
[
4.726555204480136,
52.79894952106581
]
]
]
},
"zoom": 9,
"export_zoom": 13,
"overwrite": false,
"start": "2015-01-01",
"stop": "2017-01-01",
"sink": {
"type": "asset",
"asset_path": "projects/deltares-rws/eo-bathymetry/test-collection"
}
}
Use the previously created asset to store these images as tiles in cloud storage.
{
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
4.726555204480136,
52.79894952106581
],
[
5.382988309948886,
53.2615577684405
],
[
5.226433134167636,
53.48931215536743
],
[
4.770500516980136,
53.41898585234949
],
[
4.270622587292636,
52.91018589685636
],
[
4.726555204480136,
52.79894952106581
]
]
]
},
"bucket": "eo-bathymetry-automation",
"min_zoom": 8,
"max_zoom": 10,
"image_collection": "projects/deltares-rws/eo-bathymetry/test-collection"
}
Release files for eo-bathymetry-functions 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| eo_bathymetry_functions-0.8.0.tar.gz | 14.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| eo_bathymetry_functions-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:28.9 kB
Release files / eo_bathymetry_functions-0.8.0.tar.gz
| Download URL | eo_bathymetry_functions-0.8.0.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a722d13514398906b41920a85fb250fd0a36dbba7c7a91585858539c3c9c3f2f
|
|
BLAKE2b-256 checksum How to use checksums |
8c9a9409994f3d5c3a1ad36f3ff43369e12463a3c957879c6cde05f2bc0c97c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / eo_bathymetry_functions-0.8.0-py3-none-any.whl
| Download URL | eo_bathymetry_functions-0.8.0-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d40ed3df4aa69576a63938ed2f8e1a58abc64f7fdf539e2fec0f5bfeb06d2ff
|
|
BLAKE2b-256 checksum How to use checksums |
9cb4c8e92aedfe51c937cc87b0cc310a3bca5084fc8665de39ec1abd3a9a584d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|