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.
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: ••••••'
Returns full list of vectors
X-SustGlobal-Project required | string |
[- {
- "id": 999999999,
- "name": "Wildfire Damage",
- "createDate": "2024-03-20",
- "updateDate": "2024-03-21",
- "status": "available"
}
]
Add a new vector to the compositions api
X-SustGlobal-Project required | string |
Create a new vector
{ "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 } } } } } }
{- "id": 999999999,
- "name": "Wildfire Damage",
- "createDate": "2024-03-20",
- "updateDate": "2024-03-21",
- "status": "available"
}
Apply a vector layer to a portfolio of assets
vectorId required | string ID of vector to apply |
portfolio required | string Portfolio name |
X-SustGlobal-Project required | string |
{- "name": "GDP x Wildfire Risk",
- "csv": "..."
}
Add a new user-defined function to the compositions api
Create a new UDF
{- "name": "Sum Physical Loss",
- "equation": {
- "inputLayers": [
- "county_level_risks"
], - "operation": ".loss_flood_bsln + .loss_wildfire_bsln + .loss_cyclone_bsln"
}
}
{- "id": 5555555555,
- "name": "Sum Physical Loss",
- "createDate": "2025-01-17",
- "updateDate": "2025-01-17"
}
Runs a single user-defined function, returns resulting layer
udfId required | string ID of UDF to run |
{- "id": 999999999,
- "name": "Wildfire Damage",
- "createDate": "2024-03-20",
- "updateDate": "2024-03-21",
- "status": "available"
}
Update an existing vector by id
X-SustGlobal-Project required | string |
Update an existent vector
geojson | string <binary> |
name | string |
{- "id": 999999999,
- "name": "Wildfire Damage",
- "createDate": "2024-03-20",
- "updateDate": "2024-03-21",
- "status": "available"
}
Returns a single vector
vectorId required | string ID of vector to return |
X-SustGlobal-Project required | string |
{- "id": 999999999,
- "name": "Wildfire Damage",
- "createDate": "2024-03-20",
- "updateDate": "2024-03-21",
- "status": "available",
- "geojson": { }
}
Update an existing user-defined function by id
Update an existent UDF
name | string |
object |
{- "name": "string",
- "equation": {
- "inputLayers": [
- "GDP"
], - "outputLayer": "Wildfire Damage x GDP",
- "operation": ".loss_flood_bsln + .loss_wildfire_bsln + .loss_cyclone_bsln"
}
}
{- "id": 999999999,
- "name": "Wildfire Damage",
- "createDate": "2024-03-20",
- "updateDate": "2024-03-21",
- "status": "available"
}
Returns a single user-defined function
udfId required | string ID of UDF to return |
{- "id": 999999999,
- "name": "Wildfire Damage x GDP",
- "createDate": "2024-09-17",
- "updateDate": "2024-09-17",
- "equation": {
- "inputLayers": [
- "GDP"
], - "outputLayer": "Wildfire Damage x GDP",
- "operation": "Wildfire Damage / GDP"
}
}