API to extract individual feature data from BC SAR data stores.
Provides an interface to count and extract features within a given bounding box, clipped to that bounding box, from a specified dataset.
Assumes Python >= 3.8, virtual environment recommended. Requires:
- Docker
- jq
- GDAL
Conda Virtual Environment example conda create -y --name bcsar-ext python=3.8 gdal jq && conda activate bcsar-ext
Execute scripts/local.sh
to install python dependencies and configure pre-commit hooks.
This project cannot be run without first satisfying its data requirements.
The BC Digital Road Atlas is required by this project, and is the source of the TRANSPORT_LINE layer. Download via FTP using the information here and unzip.
This project assumes the developer maintains or has access to a GeoPackage containing Trails and Shelters layers, that will be made available via the API. A template (empty) GeoPackage is available here. Before making changes to this GeoPackage copy it elsewhere so that changes are not committed.
Execute scripts/conversion.sh
and follow the prompts to generate data, in the correct formats, required to run locally. This is only required once per data update and may take over an hour, depending on the development environment.
The following environment variables are mandatory:
creds_hash
: hash of a valid username / password. Executescripts/creds.sh --user <username> --pass <password>
to generate a hash for a new user.
The following environment variables are optional:
out_data_dir
: identifies the directory used to store generated datasets, defaults to local tmp location.
Execute scripts/test.sh
Execute docker compose build && docker compose up http-tile-server
before attempting to debug the API in vscode as a local HTTP tile server is required.
While debugging navigate to http://localhost:8123/
{
"version": "0.2.0",
"configurations": [
{
"name": "api",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"feature_extract_api.app:app",
"--host", "0.0.0.0",
"--port", "8123",
"--reload"
],
"env": {
"creds_hash": "...", # replace with hash generated by scripts/creds.sh
"fgb_access_prefix": "${workspaceFolder}/feature_extract/data/fgb-data",
"mvt_bucket_name": "tiles",
"s3_endpoint": "localhost:8987"
},
"console": "integratedTerminal",
"justMyCode": false
}, {
"name": "pytest-lib",
"type": "python",
"request": "launch",
"module": "pytest",
"console": "integratedTerminal",
"justMyCode": false,
"args": [
"${workspaceFolder}/feature_extract/tests"
],
"env": {
"fgb_access_prefix": "${workspaceFolder}/feature_extract/tests/data",
"mvt_bucket_name": "required-but-not-used"
}
}, {
"name": "pytest-api",
"type": "python",
"request": "launch",
"module": "pytest",
"console": "integratedTerminal",
"justMyCode": false,
"args": [
"${workspaceFolder}/feature_extract_api/tests"
],
"env": {
"fgb_access_prefix": "required-but-not-used",
"mvt_bucket_name": "required-but-not-used"
}
}
]
}