Package: pandarus-remote
Pandarus_remote is a web service for processing and managing data for regionalized life cycle assessment usingpandarus. It is meant to be used by thebrightway2-regionallibrary.ContentsInstallationRequirementsRunning the web serviceEnvironment variablesAPI endpoints//catalogResponse/uploadParametersResponses/intersectionParametersResponses/intersection-fileParametersResponses/calculate-intersectionParametersResponses/remainingParametersResponses/calculate-remainingParametersResponses/rasterstatsParametersResponses/calculate-rasterstatsParametersResponses/status/<job_id>ReponseInstallationpandarus_remotecan be installed using pip, but your life will be much easier if you usecondato get consistent dependencies:condaconfig--addchannelsconda-forgecondaconfig--addchannelscmutelcondacreate-npandaruspython=3.9condaactivatepandaruscondainstallpandarus_remoteRequirementspandarus_remoterequires the following Python libraries:appdirsdocoptfionaflaskpandaruspeeweeredisrasteriorequestsrqIn addition,pandarus_remoterequires thatRedisbe installed.Running the web serviceA Redis server must be running on the local machine.A worker process forrqshould be started with the commandrq worker.Finally, run theflaskapplication any way you want. For example, to run the test server (not in production!), do:exportFLASK_APP=/path/to/pandarus_remote/__init__.pyflaskrunEnvironment variablesThe following environment variables can be used to configurepandarus_remote:PANDARUS_EXPORT_FORMAT: A string specifying the Fiona driver to use, like “GPKG” or “GeoJSON”PANDARUS_CPUS: The number of CPUs to use when performing intersection calculationsAPI endpointsThe following API endpoints are supported:/Ping the server. Returns something likepandarus_remote web service, version (1, 0).HTTP method:GET/catalogGet the list of spatial datasets and results currently available on the server.HTTP method:GETResponse200: Return a JSON payload of the form:['files':[('file name','hex-encoded sha256 hash of file contents','type of file')],'intersections':[('input file 1 sha256 hash','input file 2 sha256 hash')],'remaining':[('input file 1 sha256 hash','input file 2 sha256 hash')],'rasterstats':[('vector file sha256 hash','raster file sha256 hash')]]/uploadUpload a spatial data file. The provided file must be openable byfionaorrasterio.HTTP method:POSTParametersPost the following required form data:name: File namesha256: SHA 256 hash of fileband: Raster band number. This field is required; pass''if single-band raster or vector dataset.layer: Vector layer name. This field is required; pass''if single-layer vector or raster dataset.field: Vector field that uniquely identifies spatial features. This field is required; pass''if raster dataset.The file should be in the fieldfile.Responses201: The file was uploaded and registered. Returns a JSON payload:{'filename':'some file name','sha256':'hex-encoded sha256 hash of file contents'}400: The request form was missing a required field406: The input data was invalid (either the hash wasn’t correct or the file isn’t a readable geospatial dataset)409: File already exists413: The uploaded file was too large (current limit is 250 MB)/intersectionRequest the download of a pandarus intersections JSON data file for two spatial datasets. Both spatial datasets should already be on the server (see/upload), and the intersection should already be calculated (see/calculate-intersection).HTTP method:POSTParametersPost the following form data:first: SHA 256 hash of first input filesecond: SHA 256 hash of second input fileResponses200: The requested file will be returned400: The request form was missing a required field404: An intersections file for this combination was not found/intersection-fileRequest the download of the new geospatial vector file created when calculating the intersection of two spatial datasets. Both spatial datasets should already be on the server (see/upload), and the intersection should already be calculated (see/calculate-intersection).HTTP method:POSTParametersPost the following form data:first: SHA 256 hash of first input filesecond: SHA 256 hash of second input fileResponses200: The requested file will be returned400: The request form was missing a required field404: An intersections file for this combination was not found/calculate-intersectionCalculate a pandarus intersections file for two vector spatial datasets. Both spatial datasets should already be on the server (see/upload). The second vector dataset must have the geometry typePolygonorMultiPolygon.HTTP method:POSTParametersPost the following form data:first: SHA 256 hash of first input filesecond: SHA 256 hash of second input fileResponses200: The requested intersections file will be calculated. Returns the URL of the job status resource (see/status) which can be polled to see when the calculation is finished.400: The request form was missing a required field404: One of the files were not found406: Error in the files: Either the hashes were identical, or the files weren’t vector datasets, or the second file didn’t have the correct geometry type.409: The requested intersection file already exists/remainingRequest the download of the JSON data file from a remaining areas calculation. Both spatial datasets should already be on the server (see/upload), and the remaining areas should already be calculated (see/calculate-remaining).HTTP method:POSTParametersPost the following form data:first: SHA 256 hash of first input filesecond: SHA 256 hash of second input fileResponses200: The requested file will be returned400: The request form was missing a required field404: An remaining areas file for this combination was not found/calculate-remainingCalculate a pandarus remaining areas file for two vector spatial datasets. See the Pandarus documentation for more details on remaining areas. Both spatial datasets should already be on the server (see/upload), and their intersection should already be calculated.HTTP method:POSTParametersPost the following form data:first: SHA 256 hash of first input filesecond: SHA 256 hash of second input fileResponses200: The requested remaining areas file will be calculated. Returns the URL of the job status resource (see/status) which can be polled to see when the calculation is finished.400: The request form was missing a required field404: One of the files or the calculated intersection result were not found409: The requested remaining areas file already exists/rasterstatsRequest the download of the JSON data file from a raster stats calculation. Both spatial datasets should already be on the server (see/upload), and the raster stats should already be calculated (see/calculate-rasterstats).HTTP method:POSTParametersPost the following form data:vector: SHA 256 hash of vector input fileraster: SHA 256 hash of raster input fileResponses200: The requested file will be returned400: The request form was missing a required field404: An raster stats file for this combination was not found/calculate-rasterstatsCalculate a pandarus raster stats file for two vector spatial datasets. See the Pandarus documentation for more details on raster stats. Both spatial datasets should already be on the server (see/upload), and their intersection should already be calculated.HTTP method:POSTParametersPost the following form data:vector: SHA 256 hash of vector input fileraster: SHA 256 hash of raster input fileResponses200: The requested raster stats file will be calculated. Returns the URL of the job status resource (see/status) which can be polled to see when the calculation is finished.400: The request form was missing a required field404: One of the files was not found406: One of the files had an incorrect data type409: The requested remaining areas file already exists/status/<job_id>Get the status of a currently running job. Job status URLs are returned by the/calculate-intersectionand/calculate-areaendpoints.HTTP method:GETReponse200: Returns a text response giving the current job status. If the job is finished, the response will befinished.404: The requested job id was not found