Compositions API (beta)

Download OpenAPI specification:Download

Geospatial compositions the process by which user defined functions (UDFs) are applied to geospatial and non-geospatial datasets to create new geospatial datasets. The UDFs can be simple operations like vector level addition or multiplication across layers or more complex like inference from an AI model. The input data can be raster or vector.

Example Workflow

First, add a new vector. This vector will contain the data to perform operations on. In the case of this example, it's wildfire loss data.

curl --location 'https://explorer.sustglobal.io/api/compositions/vector' \
     --header 'X-SustGlobal-Project: compose-demo' \
     --header 'X-SustGlobal-APIKey: ••••••'
     --header 'Content-Type: application/json' \
     --data '{
         "name": "wildfire_loss",
         "geojson": {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-81.688246,40.999109],[-81.688491,40.988588],[-81.6818,40.988571]]]},"properties":{"loss_wildfire_bsln":0.00001,"loss_wildfire_2050":0.00004,}},
     }'

Next, add a new UDF. This UDF takes the wildfire loss in 2050 and subtracts the baseline wildfire loss. Note UDFs are written in JQ.

curl --location 'https://explorer.sustglobal.io/api/compositions/udf' \
     --header 'X-SustGlobal-Project: compose-demo' \
     --header 'X-SustGlobal-APIKey: ••••••'
     --header 'Content-Type: application/json' \
     --data '{
         "name": "wildfire_loss_delta",
         "equation": {
          "inputLayers": [
            "wildfire_loss"
          ],
          "operation": ".features.[].properties
                        | if .loss_wildfire_bsln == 0 then nan else
                            (.loss_wildfire_2050 - .loss_wildfire_bsln) / .loss_wildfire_bsln 
                           end
                        | [., 0.0] | max
                        | [., 2.0] | min"
         }
     }'

The return value will look something like this:

{
  "id": "4444444444",
  "name": "wildfire_loss_delta",
  "createDate": "2025-01-17",
  "updateDate": "2025-01-17"
}

Activate your UDF once you've created it. This will make the result vector available in your project. (Use the ID from the previous return value in the new url)

curl --location 'https://explorer.sustglobal.io/api/compositions/udf/4444444444/activate' \
     --header 'X-SustGlobal-Project: compose-demo' \
     --header 'X-SustGlobal-APIKey: ••••••'

The return value will look something like this:

{
  "id": "999999999",
  "name": "wildfire_loss_delta",
  "createDate": "2024-03-20",
  "updateDate": "2024-03-21",
  "status": "available"
}

Congrats! You can now use your new vector on any portfolios in your project.

curl --location 'https://explorer.sustglobal.io/api/compositions/vector/999999999/apply?portfolio=test-portfolio' \
     --header 'X-SustGlobal-Project: compose-demo' \
     --header 'X-SustGlobal-APIKey: ••••••'

vector

Manage Vector Layers

Get all vectors

Returns full list of vectors

Authorizations:
sustglobal_apikey
header Parameters
X-SustGlobal-Project
required
string

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Add a new vector

Add a new vector to the compositions api

Authorizations:
sustglobal_apikey
header Parameters
X-SustGlobal-Project
required
string
Request Body schema: multipart/form-data

Create a new vector

object (LockedVectorUpload)

Responses

Request samples

Content type
multipart/form-data
{
  "name": "Wildfire Damage",
  "geojson": {
    "type": "Feature",
    "properties": {
      "lat": "37.82462",
      "lng": "-92.20766",
      "labels": {
        "label:fid": 2037,
        "label:LSAD": "06",
        "label:NAME": "Pulaski",
        "label:ALAND": 1417014581,
        "label:GEOID": "29169",
        "label:AWATER": 11312724,
        "label:STUSPS": "MO",
        "label:STATEFP": "29",
        "label:AFFGEOID": "0500000US29169",
        "label:COUNTYFP": "169",
        "label:COUNTYNS": "00758539",
        "label:NAMELSAD": "Pulaski County",
        "label:STATE_NAME": "Missouri"
      },
      "scenario_analytics": {
        "ssp585": {
          "wildfire": {
            "summary_score_30yr": 0,
            "summary_label_30yr": "LOW",
            "summary_score_15yr": 0,
            "summary_label_15yr": "LOW",
            "indicator_baseline": 0,
            "indicator_baseline_lbd": 0,
            "indicator_baseline_ubd": 0,
            "indicator_2030": 0,
            "indicator_2030_lbd": 0,
            "indicator_2030_ubd": 0,
            "indicator_2050": 0,
            "indicator_2050_lbd": 0,
            "indicator_2050_ubd": 0,
            "indicator_2080": 0,
            "indicator_2080_lbd": 0,
            "indicator_2080_ubd": 0,
            "structural_damage_baseline": 0,
            "structural_damage_baseline_lbd": 0,
            "structural_damage_baseline_ubd": 0,
            "structural_damage_2030": 0,
            "structural_damage_2030_lbd": 0,
            "structural_damage_2030_ubd": 0,
            "structural_damage_2050": 0,
            "structural_damage_2050_lbd": 0,
            "structural_damage_2050_ubd": 0,
            "structural_damage_2080": 0,
            "structural_damage_2080_lbd": 0,
            "structural_damage_2080_ubd": 0,
            "business_interruption_baseline": 0,
            "business_interruption_baseline_lbd": 0,
            "business_interruption_baseline_ubd": 0,
            "business_interruption_2030": 0,
            "business_interruption_2030_lbd": 0,
            "business_interruption_2030_ubd": 0,
            "business_interruption_2050": 0,
            "business_interruption_2050_lbd": 0,
            "business_interruption_2050_ubd": 0,
            "business_interruption_2080": 0,
            "business_interruption_2080_lbd": 0,
            "business_interruption_2080_ubd": 0
          }
        }
      }
    }
  }
}

Response samples

Content type
application/json
{
  • "id": 999999999,
  • "name": "Wildfire Damage",
  • "createDate": "2024-03-20",
  • "updateDate": "2024-03-21",
  • "status": "available"
}

Apply a vector

Apply a vector layer to a portfolio of assets

Authorizations:
sustglobal_apikey
path Parameters
vectorId
required
string

ID of vector to apply

query Parameters
portfolio
required
string

Portfolio name

header Parameters
X-SustGlobal-Project
required
string

Responses

Response samples

Content type
application/json
{
  • "name": "GDP x Wildfire Risk",
  • "csv": "..."
}

udf

Create User-Defined Functions

Get all UDFs

Returns full list of user-defined functions

Authorizations:
sustglobal_apikey

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Add a new UDF

Add a new user-defined function to the compositions api

Authorizations:
sustglobal_apikey
Request Body schema: application/json

Create a new UDF

object (LockedUdfUpload)

Responses

Request samples

Content type
application/json
{
  • "name": "Sum Physical Loss",
  • "equation": {
    }
}

Response samples

Content type
application/json
{
  • "id": 5555555555,
  • "name": "Sum Physical Loss",
  • "createDate": "2025-01-17",
  • "updateDate": "2025-01-17"
}

Run a UDF

Runs a single user-defined function, returns resulting layer

Authorizations:
sustglobal_apikey
path Parameters
udfId
required
string

ID of UDF to run

Responses

Response samples

Content type
application/json
{
  • "id": 999999999,
  • "name": "Wildfire Damage",
  • "createDate": "2024-03-20",
  • "updateDate": "2024-03-21",
  • "status": "available"
}

admin

Administrate Compositions

Update an existing vector

Update an existing vector by id

Authorizations:
sustglobal_apikey
header Parameters
X-SustGlobal-Project
required
string
Request Body schema: multipart/form-data
required

Update an existent vector

geojson
string <binary>
name
string

Responses

Response samples

Content type
application/json
{
  • "id": 999999999,
  • "name": "Wildfire Damage",
  • "createDate": "2024-03-20",
  • "updateDate": "2024-03-21",
  • "status": "available"
}

Find vector by ID

Returns a single vector

Authorizations:
sustglobal_apikey
path Parameters
vectorId
required
string

ID of vector to return

header Parameters
X-SustGlobal-Project
required
string

Responses

Response samples

Content type
application/json
{
  • "id": 999999999,
  • "name": "Wildfire Damage",
  • "createDate": "2024-03-20",
  • "updateDate": "2024-03-21",
  • "status": "available",
  • "geojson": { }
}

Delete a vector

Delete a single vector from the compositions api

Authorizations:
sustglobal_apikey
path Parameters
vectorId
required
string

ID of vector to delete

header Parameters
X-SustGlobal-Project
required
string

Responses

Update an existing UDF

Update an existing user-defined function by id

Authorizations:
sustglobal_apikey
Request Body schema: application/json
required

Update an existent UDF

name
string
object

Responses

Request samples

Content type
application/json
{
  • "name": "string",
  • "equation": {
    }
}

Response samples

Content type
application/json
{
  • "id": 999999999,
  • "name": "Wildfire Damage",
  • "createDate": "2024-03-20",
  • "updateDate": "2024-03-21",
  • "status": "available"
}

Find a UDF by ID

Returns a single user-defined function

Authorizations:
sustglobal_apikey
path Parameters
udfId
required
string

ID of UDF to return

Responses

Response samples

Content type
application/json
{
  • "id": 999999999,
  • "name": "Wildfire Damage x GDP",
  • "createDate": "2024-09-17",
  • "updateDate": "2024-09-17",
  • "equation": {
    }
}

Delete a UDF

Delete a single user-defined function from the compositions api

Authorizations:
sustglobal_apikey
path Parameters
udfId
required
string

ID of UDF to delete

Responses