.. _gdal_wcs_output_format: GDAL based WCS Output Format ============================ The gdal_translate based output format leverages the availability of the gdal_translate command to allow the generation of more output formats than GeoServer can natively produce. The basic idea is to dump to the file system a file that gdal_translate can translate, invoke it, zip and return the output of the translation. This extension is thus the equivalent of the :ref:`OGR extension ` for raster data. Out of the box behaviour ------------------------ Out of the box the plugin assumes the following: * gdal_translate is available in the path * the GDAL_DATA variable is pointing to the GDAL data directory (which stores the spatial reference information for GDAL) In the default configuration the following formats are supported: * JPEG-2000 part 1 (ISO/IEC 15444-1) * Geospatial PDF * Arc/Info ASCII Grid * ASCII Gridded XYZ The list might be shorter if gdal_translate has not been built with support for the above formats (for example, the default JPEG-2000 format relies on the `JasPer-based GDAL driver `_). Once installed in GeoServer, a bunch of new supported formats will be listed in the ``ServiceMetadata`` section of the WCS 2.0 GetCapabilities document, e.g. ``image/jp2`` and ``application/pdf``. gdal_translate conversion abilities ----------------------------------- The gdal_translate utility is usually able to convert more formats than the default setup of this output format allows for, but the exact list depends on how the utility was built from sources. To get a full list of the formats available by your ogr2ogr build just run:: gdal_translate --long-usage and you'll get the full set of options usable by the program, along with the supported formats. .. include:: usage_example.txt The full list of formats that gdal_translate is able to support is available on the `GDAL site `_. Mind that this output format can handle only outputs that are file based and that do support creation. So, for example, you won't be able to use the PostGIS Raster output (since it's database based) or the Arc/Info Binary Grid (creation not supported). Customisation ------------- If gdal_translate is not available in the default path, the GDAL_DATA environment variable is not set, or if the output formats needs tweaking, a ``gdal_translate.xml`` configuration file can be created to customize the output format. The file should be put inside a ``gdal`` folder in the root of the GeoServer data directory. .. note:: GeoServer will automatically detect any change to the file and reload the configuration, without a need to restart. The default configuration is equivalent to the following xml file: .. code-block:: xml gdal_translate JPEG2000 GDAL-JPEG2000 .jp2 true image/jp2 binary PDF GDAL-PDF .pdf true application/pdf AAIGrid GDAL-ArcInfoGrid .asc false XYZ GDAL-XYZ .txt true text/plain text The file showcases all possible usage of the configuration elements: * ``executable`` can be just gdal_translate if the command is in the path, otherwise it should be the full path to the executable. For example, on a Linux box with a custom build GDAL library might be:: /usr/local/bin/gdal_translate * ``environment`` contains a list of ``variable`` elements, which can be used to define environment variables that should be set prior to invoking gdal_translate. For example, to setup a GDAL_DATA environment variable pointing to the GDAL data directory, the configuration might be:: * ``Format`` defines a single format, which is defined by the following tags: * ``toolFormat``: the name of the format to be passed to gdal_translate with the -of option (case insensitive). * ``geoserverFormat``: is the name of the output format as advertised by GeoServer * ``fileExtension``: is the extension of the file generated after the translation, if any (can be omitted) * ``option``: can be used to add one or more options to the gdal_translate command line. As you can see by the JPEG2000 example, each item must be contained in its own ``option`` tag. You can get a full list of options by running ``gdal_translate --help`` or by visiting the `GDAL web site `_). Also, consider that each format supports specific creation options, listed in the description page for each format (for example, here is the `JPEG2000 one `_). * ``singleFile``: if true the output of the conversion is supposed to be a single file that can be streamed directly back without the need to wrap it into a zip file * ``mimeType``: the mime type of the file returned when using ``singleFile``. If not specified ``application/octet-stream`` will be used as a default. * ``formatAdapters``: transformations on the coverage that might need to be applied in order to successfully encode the output. The transformations are applied only if their input conditions are met. The available format adapters are: * ``GrayAlphaToRGBA``: expands a gray image with alpha channel to RGBA (mandatory for geospatial PDF for example) * ``PallettedToRGB``: expands a paletted image RGB(A) (mandatory for geospatial PDF for example)