An open-source API deployed as a Python Azure Function to allow a client to query for a raster value at a specified set of coordinates in a specified raster file (preferably in COG format). An alternate version of the API deployed as a FastAPI application (with associated requirements file) is available for users who don't have access to Microsoft Azure. In addition, a second API endpoint is included that does not query a raster file, but instead calculates the confidence interval for a specified depth and standard deviation.
- Clone the repository to a local directory.
- Install Python 3.11 on your system.
- Use Python 3.11 to create a virtual environment in the local directory using the
venv
command (preferably called.venv
). - Install the Azure Functions extension in VS Code.
- Open the project in VS Code and set the Python interpreter to
.\.venv\Scripts\python.exe
. - Set an environment variable AZURE_STORAGE_CONNECTION_STRING to the connection string to an Azure Storage account where the raster files are stored.
- Use the Debug panel to start the application locally and debug its code.
POST https://{host}/api/get_values
- 'file': a string containing the name of the file in the storage account, not the full path
- 'bands': an array containing at least one integer indicating the raster band(s) to read data from
- 'lat': a floating point latitude coordinate in decimal degrees
- 'lon': a floating point longitude coordinate in decimal degrees
POST https://{host}/api/get_ci_values
- 'haz_stats': an object containing a floating point 'mean' property and a floating point 'std_dev' property
- 'realizations': an optional integer indicating the number of realizations in the study (default: 5)
- 'distribution': an optional string indicating the z score to use (default: 'normal')
- 'confidence_level': an optional floating point indicating the range of the z score distribution (default: 0.9)