The application uses Spring Data Cassandra and DataStax Astra DB to build a REST API for a Spatio-Temporal Asset Catalog (STAC) that can scale to hundreds of billions of STAC items.
Run a REST API that connects to DataStax Astra DB
We're using Spring Data Cassandra and Datastax Astra DB to build a REST API that stores STAC items and features.
Click on end points to perform GET or POST action. Click on "Try it out" button to key in
input data
{
"stac_version": "1.0.0",
"stac_extensions": [],
"type": "Feature",
"id": "20240725_232000_BILGI02",
"bbox": [172.91173669923782, 1.3438851951615003, 172.95469614953714, 1.3690476620161975],
"geometry": {
"type": "Polygon",
"coordinates": [[[172.91173669923782, 1.3438851951615003], [172.95469614953714, 1.3438851951615003],
[172.95469614953714, 1.3690476620161975], [172.91173669923782, 1.3690476620161975], [172.91173669923782, 1.3438851951615003]]]
},
"properties": {
"title": "Core Item",
"description": "A sample STAC Item that includes examples of all common metadata",
"start_datetime": "2020-12-11T22:38:32.125Z",
"end_datetime": "2020-12-11T22:38:32.327Z",
"created": "2020-12-12T01:48:13.725Z",
"updated": "2020-12-12T01:48:13.725Z",
"platform": "cool_sat1",
"eo:cloud_cover": 13.1,
"instruments": ["cool_sensor_v1"],
"constellation": "ion",
"mission": "collection 5624",
"gsd": 0.512
},
"collection": "BILGI Test 02"
}
Copy and past above string in put box and make necessary changes. It would be like below.
For polygon
{
"id": "20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798",
"geometry": {
"type": "Polygon",
"crs": {
"type": "name",
"properties": {
"name": "EPSG:4326"
}
},
"coordinates": [
[
[
144.81543,
-37.927299
],
[
144.814896,
-37.945313
],
[
144.83763,
-37.945733
],
[
144.838158,
-37.927719
],
[
144.81543,
-37.927299
]
]
]
},
"collection": "quickview-visual",
"datetime": "2023-01-30T01:01:30.760099+00:00",
"end_datetime": "2023-01-30T01:01:30.760099+00:00",
"content": {
"bbox": [
144.814896,
-37.945733,
144.838158,
-37.927299
],
"links": [],
"assets": {
"cloud": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_CLOUD/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_CLOUD_1_1_3_SATL-2KM-55S_308_5798.tif",
"type": "image/tiff; application=geotiff;",
"roles": [
"cloud"
]
},
"preview": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_VISUAL/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798_preview.png",
"type": "image/png",
"roles": [
"overview"
]
},
"analytic": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_VISUAL/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798.tif",
"type": "image/tiff; application=geotiff;",
"roles": [
"data"
],
"eo:bands": [
{
"name": "Red",
"common_name": "red"
},
{
"name": "Green",
"common_name": "green"
},
{
"name": "Blue",
"common_name": "blue"
},
{
"name": "NIR",
"common_name": "nir"
}
]
},
"thumbnail": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_VISUAL/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798_thumbnail.png",
"type": "image/png",
"roles": [
"thumbnail"
]
}
},
"properties": {
"gsd": 1.24,
"datetime": "2023-01-30T01:01:30.760099328+00:00",
"platform": "newsat24",
"grid:code": "SATL-2KM-55S_308_5798",
"proj:epsg": 32755,
"proj:shape": [
1613,
1612
],
"eo:cloud_cover": 73.0,
"proj:transform": [
1.24,
0.0,
307999.88,
0.0,
-1.24,
5800000.8,
0.0,
0.0,
1.0
],
"view:off_nadir": 23.2014,
"satl:outcome_id": "88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813",
"satl:ground_lock": false,
"satl:valid_pixel": 0.153,
"view:sun_azimuth": 51.5664,
"satl:product_name": "QUICKVIEW_VISUAL",
"satl:shadow_cover": 1.9,
"satl:ba_nir_radial": 1.146,
"satl:ba_nir_xshift": -1.139,
"satl:ba_nir_yshift": -0.123,
"satl:ba_red_radial": 2.964,
"satl:ba_red_xshift": -2.964,
"satl:ba_red_yshift": -0.005,
"view:sun_elevation": 61.6236,
"satl:ba_blue_radial": 0.82,
"satl:ba_blue_xshift": 0.019,
"satl:ba_blue_yshift": 0.82,
"satl:transaction_id": "rr-to-stac-vh9c7",
"satl:ba_nir_response": 0.601,
"satl:ba_red_response": 0.645,
"satl:product_version": "1.1.3",
"satl:ba_blue_response": 0.492,
"satl:geoaccuracy_red_radial": 105.189,
"satl:geoaccuracy_red_xshift": -71.555,
"satl:geoaccuracy_red_yshift": 77.101,
"satl:geoaccuracy_blue_radial": 171.945,
"satl:geoaccuracy_blue_xshift": 171.944,
"satl:geoaccuracy_blue_yshift": -0.237,
"satl:geoaccuracy_green_radial": 1.821,
"satl:geoaccuracy_green_xshift": 0.364,
"satl:geoaccuracy_green_yshift": 1.784,
"satl:geoaccuracy_red_response": 0.134,
"satl:geoaccuracy_blue_response": -0.045,
"satl:geoaccuracy_green_response": 0.174
},
"stac_extensions": [
"https://stac-extensions.github.io/projection/v1.1.0/schema.json",
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json",
"https://stac-extensions.github.io/grid/v1.1.0/schema.json"
]
},
"private": null
}
For point
{
"id": "20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798",
"geometry": {
"type": "Point",
"crs": {
"type": "name",
"properties": {
"name": "EPSG:4326"
}
},
"coordinates": [
144.81543,
-37.927299
]
},
"collection": "quickview-visual",
"datetime": "2023-01-30T01:01:30.760099+00:00",
"end_datetime": "2023-01-30T01:01:30.760099+00:00",
"content": {
"bbox": [
144.814896,
-37.945733,
144.838158,
-37.927299
],
"links": [],
"assets": {
"cloud": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_CLOUD/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_CLOUD_1_1_3_SATL-2KM-55S_308_5798.tif",
"type": "image/tiff; application=geotiff;",
"roles": [
"cloud"
]
},
"preview": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_VISUAL/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798_preview.png",
"type": "image/png",
"roles": [
"overview"
]
},
"analytic": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_VISUAL/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798.tif",
"type": "image/tiff; application=geotiff;",
"roles": [
"data"
],
"eo:bands": [
{
"name": "Red",
"common_name": "red"
},
{
"name": "Green",
"common_name": "green"
},
{
"name": "Blue",
"common_name": "blue"
},
{
"name": "NIR",
"common_name": "nir"
}
]
},
"thumbnail": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_VISUAL/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798_thumbnail.png",
"type": "image/png",
"roles": [
"thumbnail"
]
}
},
"properties": {
"gsd": 1.24,
"datetime": "2023-01-30T01:01:30.760099328+00:00",
"platform": "newsat24",
"grid:code": "SATL-2KM-55S_308_5798",
"proj:epsg": 32755,
"proj:shape": [
1613,
1612
],
"eo:cloud_cover": 73.0,
"proj:transform": [
1.24,
0.0,
307999.88,
0.0,
-1.24,
5800000.8,
0.0,
0.0,
1.0
],
"view:off_nadir": 23.2014,
"satl:outcome_id": "88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813",
"satl:ground_lock": false,
"satl:valid_pixel": 0.153,
"view:sun_azimuth": 51.5664,
"satl:product_name": "QUICKVIEW_VISUAL",
"satl:shadow_cover": 1.9,
"satl:ba_nir_radial": 1.146,
"satl:ba_nir_xshift": -1.139,
"satl:ba_nir_yshift": -0.123,
"satl:ba_red_radial": 2.964,
"satl:ba_red_xshift": -2.964,
"satl:ba_red_yshift": -0.005,
"view:sun_elevation": 61.6236,
"satl:ba_blue_radial": 0.82,
"satl:ba_blue_xshift": 0.019,
"satl:ba_blue_yshift": 0.82,
"satl:transaction_id": "rr-to-stac-vh9c7",
"satl:ba_nir_response": 0.601,
"satl:ba_red_response": 0.645,
"satl:product_version": "1.1.3",
"satl:ba_blue_response": 0.492,
"satl:geoaccuracy_red_radial": 105.189,
"satl:geoaccuracy_red_xshift": -71.555,
"satl:geoaccuracy_red_yshift": 77.101,
"satl:geoaccuracy_blue_radial": 171.945,
"satl:geoaccuracy_blue_xshift": 171.944,
"satl:geoaccuracy_blue_yshift": -0.237,
"satl:geoaccuracy_green_radial": 1.821,
"satl:geoaccuracy_green_xshift": 0.364,
"satl:geoaccuracy_green_yshift": 1.784,
"satl:geoaccuracy_red_response": 0.134,
"satl:geoaccuracy_blue_response": -0.045,
"satl:geoaccuracy_green_response": 0.174
},
"stac_extensions": [
"https://stac-extensions.github.io/projection/v1.1.0/schema.json",
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json",
"https://stac-extensions.github.io/grid/v1.1.0/schema.json"
]
},
"private": null
}
{
"id": "20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798",
"geometry": {
"type": "Polygon",
"crs": {
"type": "name",
"properties": {"name": "EPSG:4326"}
},
"coordinates": [[[144.81543, -37.927299], [144.814896, -37.945313], [144.83763, -37.945733],[144.838158,-37.927719],
[144.81543, -37.927299]]]
},
"collection": "quickview-visual",
"datetime": "2023-01-30T01:01:30.760099+00:00",
"end_datetime": "2023-01-30T01:01:30.760099+00:00",
"content": {
"bbox": [144.814896, -37.945733, 144.838158, -37.927299],
"links": [],
"assets": {
"cloud": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_CLOUD/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_CLOUD_1_1_3_SATL-2KM-55S_308_5798.tif",
"type": "image/tiff; application=geotiff;",
"roles": [
"cloud"
]
},
"preview": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_VISUAL/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798_preview.png",
"type": "image/png",
"roles": [
"overview"
]
},
"analytic": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_VISUAL/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798.tif",
"type": "image/tiff; application=geotiff;",
"roles": [
"data"
],
"eo:bands": [
{
"name": "Red",
"common_name": "red"
},
{
"name": "Green",
"common_name": "green"
},
{
"name": "Blue",
"common_name": "blue"
},
{
"name": "NIR",
"common_name": "nir"
}
]
},
"thumbnail": {
"href": "s3://satellogic-production-eo-backend-catalog/QUICKVIEW_VISUAL/88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813/20230130_010126_SN24_QUICKVIEW_VISUAL_1_1_3_SATL-2KM-55S_308_5798_thumbnail.png",
"type": "image/png",
"roles": [
"thumbnail"
]
}
},
"properties": {
"gsd": 1.24,
"datetime": "2023-01-30T01:01:30.760099328+00:00",
"platform": "newsat24",
"grid:code": "SATL-2KM-55S_308_5798",
"proj:epsg": 32755,
"proj:shape": [
1613,
1612
],
"eo:cloud_cover": 73.0,
"proj:transform": [
1.24,
0.0,
307999.88,
0.0,
-1.24,
5800000.8,
0.0,
0.0,
1.0
],
"view:off_nadir": 23.2014,
"satl:outcome_id": "88d2d7ad-1ee6-40cf-b68e-52f5ff828ecb--112813",
"satl:ground_lock": false,
"satl:valid_pixel": 0.153,
"view:sun_azimuth": 51.5664,
"satl:product_name": "QUICKVIEW_VISUAL",
"satl:shadow_cover": 1.9,
"satl:ba_nir_radial": 1.146,
"satl:ba_nir_xshift": -1.139,
"satl:ba_nir_yshift": -0.123,
"satl:ba_red_radial": 2.964,
"satl:ba_red_xshift": -2.964,
"satl:ba_red_yshift": -0.005,
"view:sun_elevation": 61.6236,
"satl:ba_blue_radial": 0.82,
"satl:ba_blue_xshift": 0.019,
"satl:ba_blue_yshift": 0.82,
"satl:transaction_id": "rr-to-stac-vh9c7",
"satl:ba_nir_response": 0.601,
"satl:ba_red_response": 0.645,
"satl:product_version": "1.1.3",
"satl:ba_blue_response": 0.492,
"satl:geoaccuracy_red_radial": 105.189,
"satl:geoaccuracy_red_xshift": -71.555,
"satl:geoaccuracy_red_yshift": 77.101,
"satl:geoaccuracy_blue_radial": 171.945,
"satl:geoaccuracy_blue_xshift": 171.944,
"satl:geoaccuracy_blue_yshift": -0.237,
"satl:geoaccuracy_green_radial": 1.821,
"satl:geoaccuracy_green_xshift": 0.364,
"satl:geoaccuracy_green_yshift": 1.784,
"satl:geoaccuracy_red_response": 0.134,
"satl:geoaccuracy_blue_response": -0.045,
"satl:geoaccuracy_green_response": 0.174
},
"stac_extensions": [
"https://stac-extensions.github.io/projection/v1.1.0/schema.json",
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json",
"https://stac-extensions.github.io/grid/v1.1.0/schema.json"
]
},
"private": null
}
To build and play with this app, follow the build instructions that are located here: https://github.com/Anant/cass-stac
-
Download the Astra CLI:
curl -Ls "https://dtsx.io/get-astra-cli" | bash
-
[Optional] Download CQLSH to be able to query the DB from the command line
Install the Python version you need for CQLSH: Python2.7+ or Python 3.6+
curl -O -L https://downloads.datastax.com/enterprise/cqlsh-astra.tar.gz curl -O https://downloads.datastax.com/enterprise/cqlsh-astra-20221114-bin.tar.gz tar xvfz cqlsh-astra.tar.gz tar xvfz cqlsh-astra-20221114-bin.tar.gz mv cqlsh-astra ~/cqlsh-astra export CQLSH_PATH=~/cqlsh-astra/ export PATH=${CQLSH_PATH}/bin:${PATH} >> ~/.bashrc
-
Create a DataStax Astra account if you don't already have one:
-
On the home page. Locate the button
Create Database
and create a vector database. -
After your database is provisioned, we need to generate an Application Token for our App. Go to the
Settings
tab in the database home screen. -
Generate a token by clicking
Generate Token
and give it a name. -
After you have your Application Token, head to the database connect screen and select the driver connection that we need. Go ahead and download the
Secure Bundle
for the driver.The bundle might be downloaded as well using the astra-cli:
astra db download-scb <db_name> -f secure-connect-db-name.zip
-
Create keyspace.
-
Once your Gitpod workspace has loaded, you'll be asked to paste your DB credentials in the Gitpod terminal at the bottom of the screen:
-
When the app is finished building, click the 'Open Browser' button on the bottom right of the screen, add /swagger-ui/index.html#/ to the end of the given URL.:
-
You've successfully built a Spring Data Datastax application!
Make sure you've completed the prerequisites before starting this step
*Additional prerequisites for local instalation*
i -> Ensure user is part of sudo group
ii -> Ensure git is installed. -> Command : "sudo apt-get install git"
iii -> Curl is installed. -> Command : "sudo apt-get install curl"
iv -> Install SDKMAN using https://gist.github.com/masudcsesust04/3c8ba2390fcd49e61851e92ea19907e2
-
Prepare Java and maven to be the Right Version
sdk list java sdk install java 17.0.12-amzn sdk list maven sdk install maven 3.9.8
-
Download SCB using astra client. Below are the steps to download SCB
a -> Open new terminal b -> Ensure astra client is installed -> Command : "astra help" c -> Install astra client if above command fails. Refer [prerequisites](#prerequisites) for installing astra client after installation follow steps from point (#a) d -> Login to astra db -> Command : "astra login -t your_astra_token_here" e -> Download SCB -> Command : "astra db download-scb astra_database_id -f secure-connect-database.zip" f -> exit from astra-cli terminal
-
Clone cass-stac git repository -> Command : "git clone https://github.com/Anant/cass-stac.git"
-
Update the right config properties files with the Database credentials
datastax.astra.username=token datastax.astra.password=## FILL IN PASSWORD FROM Datastax's UI ## datastax.astra.keyspace=<keyspace> datastax.astra.secure-connect-bundle=secure-connect-database.zip
-
Move SCB to resource directory -> Command : "mv secure-connect-database.zip src/main/resource/secure-connect-database.zip"
-
Compile and Run -> Ensure current directory is cass-stac
mvn compile mvn package -DskipTests=true mvn spring-boot:run
-
Hit http://localhost:8080/swagger-ui/index.html#/ and start using the API
-
[Optional] Connect to the DB from the command line
$CQLSH_PATH/bin/cqlsh \
-u token \
-p <password> \
-b ./secure-connect-cass5-stac.zip
Docker installed on your system.
Basic knowledge of Docker and command-line interface.
Setup database and Schema on Astra
Dockerfile: Contains the instructions to build the Docker image.
dockerignore: Lists files and directories to be ignored by Docker.
dockersetup.sh: Shell script to set up the Docker environment and download SCB from Astra.
Clone the repository containing these files to your local machine.
Use the Dockerfile to build the Docker image. Run the following command in the directory containing the Dockerfile.
sudo docker build -t container_name .
Once the container is running, you can access the application from browser using URL. Below is the command to start docker container.
docker run -p port_no:port_no \
-e SERVER_PORT=8080 \
-e ASTRA_DB_USERNAME=token \
-e ASTRA_DB_KEYSPACE=keyspace_name \
-e ASTRA_DB_ID=astra_database_id \
-e DATASTAX_ASTRA_PASSWORD=Astra_application_password \
-e DATASTAX_ASTRA_SCB_NAME=SCB.zip \
container_name
```
http://localhost:8080/swagger-ui/index.html#/
UI wold be like below
```
```
$CQLSH_PATH/bin/cqlsh \
-u token \
-p <password> \
-b ./SCB.zip
```
Docker installed on your system.
Basic knowledge of Docker and command-line interface.
Visual Studio
Setup database and Schema on Astra
Dockerfile: Contains the instructions to build the Docker image.
dockerignore: Lists files and directories to be ignored by Docker.
dockersetup.sh: Shell script to set up the Docker environment and download SCB from Astra.
setup_devcontainer.sh: Shell script to setup docker environment and create docker image
devcontainer.json: File required by Dev container
1 -> Open Visual Studio
2 -> Navigate to command palette using menu or by Ctrl + Shift + P key combination
3 -> Type "Dev Containers: Clone Repository in Container Volume" in command palette and select the same
Below option would be displayed in command palette
4 -> Paste "https://github.com/Anant/cass-stac.git" and press enter key. Below pop-up would be displayed to select repo branch. Select "main" branch.
Close / Cancel any pop-up displayed after this
Once values for all parameters are provided and on successuful deployment, output in terminal would be like below. There would be line stating "ACCEPTING TRAFFIC"
```
http://localhost:8080/swagger-ui/index.html#/
UI wold be like below
```
Press Ctrl + C in Visual Studio teminal. Below info would be displayed
As suggested in the terminal, press enter key. Terminal would be close and display would be as below
Close the folder from Visual Studio.
Open new terminal outside Visual Studio and execute ./stop_and_remove_containers.sh. Output would be like below