A tool to create a gif from a set of wms layers
Python 2.7.4 or newer Node.js to use as a service
The WMS endpoints that will be fetched are found in a configuration file in python config.py that contains the following elements:
- layerDefinitions is a map with the WMS endpoint URL as the key and an array of layerObject as the value. Each layerObject is a map with name and overlay properties. name is the layer name in the WMS endpoint and overlay is the relative path to an image that will be alpha-blended with the WMS response. View the config.py file for an example
- duration is the time in seconds between each image in the resulting gif
The gif generation is done by the gifGenerator.py python script. It has two working modes: an interactive mode where a bounding box is specified and a bulk mode where a GeoJSON file is processed to generate Gifs from different positions
Just run pip install requirements
and the numpy and imageio packages will be installed
You can run python gifGenerator.py -h
to see a reduced view of this information
- --file The name of the GeoJSON file to be processed. Used in bulk mode
- --bboxParam The name of the GeoJSON feature property where the bounding box is specified. Required in bulk mode
- --idParam The name of the GeoJSON feature property where the id is specified. Used in bulk mode. If none is present, an autoincrementing id is used.
- --bbox The bounding box requested in the WMS requests to create the GIF in the xMin,yMin,xMax,yMax format. Used in interactive mode.
- --output The name (without extension) of the output file. Used in interactive mode.
- --duration The duration in seconds of the gif. Used in bulk and interactive modes. If not present, the one in the configuration is used
- --srid The SRID used by the bounding box. Used in bulk and interactive modes. If not present, EPSG:3857 is used
Given the following GeoJSON called bboxs.json:
{
"type": "FeatureCollection",
...
"features":[
{
"type": "Feature",
"properties": {
"id": "0",
"bbox_3857": "223298.192,5076488.639,223983.217,5077308.063"
}
},
...
]
}
we can run the following command to generate a gif for each feature
python gifGenerator.py --file bboxs.json -- bboxParam bbox_3857 --idParam id
The generated gifs will be written to the generated folder.
Running the following command
python gifGenerator.py --bbox "205000.110935124,5176119.97098418,206000.110935124,5177119.97098418"
will generate a gif with a random name in the generated folder
This repo includes a Node Express server implementation that listens to a request, generates a GIF from a specified bounding box and sends an email with the link to download it to the given email.
The config.js file contains the configuration of the service.
- serverURL is the base server URL used to build the email download link
- pathMainWeb is the folder where the service is running. http://serverURL/pathMainWeb/ will be used as the service entry point.
- mailServer is the address of the mail server used to send the email to the user
- emailFrom is the email address that will be used as a sender in the email The /templates/email.html contains the email text that will be sent to the user once the GIF generation is finished. The {FILE_PATH} string will be replaced by the download URL.
The service is listening for GET requests in the pathMainWeb folder and needs bbox and email parameters
The following request http://_serverURL_/_pathMainWeb_/?bbox=&[email protected]
would generate a GIF from the given bbox and send an email with a download link to [email protected] when finishes.
Take into account that the service is using the script configuration file to generate the GIF. The python script configuration section details its content.