rawDownload.rst 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. .. _community_wpsrawdownload:
  2. Raw data download processes
  3. ---------------------------
  4. These processes allow download of vector and raster data in raw form, without rendering.
  5. Download Estimator Process
  6. +++++++++++++++++++++++++++
  7. The *Download Estimator Process* checks the size of the file to download. This process takes in input the following parameters:
  8. * ``layername`` : name of the layer to check
  9. * ``ROI`` : ROI object to use for cropping data
  10. * ``filter`` : filter for filtering input data
  11. * ``targetCRS`` : CRS of the final layer if reprojection is needed
  12. This process will return a boolean which will be **true** if the downloaded file will not exceed the configured limits.
  13. Download Process
  14. ++++++++++++++++++++++
  15. The *Download Process* calls the *Download Estimator Process*, checks the file size, and, if the file does not exceed the limits, download the file as a zip.
  16. The parameters to set are
  17. * ``layerName`` : the name of the layer to process/download
  18. * ``filter`` : a vector filter for filtering input data(optional)
  19. * ``outputFormat`` : the MIME type of the format of the final file
  20. * ``targetCRS`` : the CRS of the output file (optional)
  21. * ``RoiCRS`` : Region Of Interest CRS (optional)
  22. * ``ROI`` : Region Of Interest object to use for cropping data (optional)
  23. * ``cropToROI`` : boolean parameter to allow cropping to actual ROI, or its envelope (optional)
  24. * ``interpolation`` : interpolation function to use when reprojecting / scaling raster data. Values are NEAREST (default), BILINEAR, BICUBIC2, BICUBIC (optional)
  25. * ``targetSizeX`` : size X in pixels of the output (optional, applies for raster input only)
  26. * ``targetSizeY`` : size Y in pixels of the output (optional, applies for raster input only)
  27. * ``selectedBands`` : a set of the band indices of the original raster that will be used for producing the final result (optional, applies for raster input only)
  28. * ``writeParameters`` : a set of writing parameters (optional, applies for raster input only). See :ref:`writing_params` below section for more details on writing parameters defintion.
  29. * ``minimizeReprojections`` : since 2.17, parameter to control CRS management when dealing with heterogeneous CRS's coverages, in order to minimize reprojections when granules in ROI match the TargetCRS. See :ref:`heterogeneous_imagemosaic` below section for more details on this param.
  30. * ``bestResolutionOnMatchingCRS`` : since 2.17, parameter to control CRS and resolution management when dealing with heterogeneous CRS's coverages. See :ref:`heterogeneous_imagemosaic` below section for more details on this param.
  31. * ``targetVerticalCRS`` : optional TargetVerticalCRS, to be used to transform elevation data from a VerticalCRS to another one. See :ref:`vertical_resampling` below section for more details on this param
  32. * ``resolutionsDifferenceTolerance`` : the parameter allows to specify a tolerance value to control the use of native resolution of the data, when no target size has been specified and granules are reprojected. If
  33. * the percentage difference between original and reprojected coverages resolutions is below the specified tolerance value,
  34. * native resolution is the same for all the requested granules,
  35. * the unit of measure is the same for native and target CRS,
  36. the reprojected coverage will be forced to use native resolutions.
  37. For example by specifying a value of 5.0, if the percentage difference between native and reprojected data is below 5%, assuming that also the other two conditions are respected, the native resolutions will be preserved. Default values is 0.
  38. The ``targetCRS`` and ``RoiCRS`` parameters are using EPSG code terminology, so, valid parameters are literals like ``EPSG:4326`` (if we are referring to a the Geogaphic WGS84 CRS), ``EPSG:3857`` (for WGS84 Web Mercator CRS), etc.
  39. ROI Definition
  40. ++++++++++++++++++++++
  41. A ``ROI`` parameter is a geometry object which can also be defined if three different forms:
  42. * as ``TEXT``, in various geometry textual formats/representations
  43. * as ``REFERENCE``, which is the textual result of an HTTP GET/POST request to a specific url
  44. * as a ``SUPPROCESS`` result: the format produced as result of the process execution must be a compatible geometry textual format.
  45. As noted above, in all above forms/cases ROI geometry is defined as text, in specific formats. These can be:
  46. * ``text/xml; subtype=gml/3.1.1``: conforming to gml specs 3.1.1
  47. * ``text/xml; subtype=gml/2.1.2``: conforming to gml specs 2.1.2
  48. * ``application/wkt``: the WKT geometry representation
  49. * ``application/json``: the JSON geometry representation
  50. * ``application/gml-3.1.1``: conforming to gml specs 3.1.1
  51. * ``application/gml-2.1.2``: conforming to gml specs 2.1.2
  52. For example, a polygon used as ROI with the following WKT representation:
  53. ``POLYGON (( 500116.08576537756 499994.25579707103, 500116.08576537756 500110.1012210889, 500286.2657688021 500110.1012210889, 500286.2657688021 499994.25579707103, 500116.08576537756 499994.25579707103 ))``
  54. would be represented in the following forms:
  55. * in application/wkt: ``POLYGON (( 500116.08576537756 499994.25579707103, 500116.08576537756 500110.1012210889, 500286.2657688021 500110.1012210889, 500286.2657688021 499994.25579707103, 500116.08576537756 499994.25579707103 ))``
  56. * in application/json: ``{"type":"Polygon","coordinates":[[[500116.0858,499994.2558],[500116.0858,500110.1012],[500286.2658,500110.1012],[500286.2658,499994.2558],[500116.0858,499994.2558]]]}``
  57. * in text/xml:``500116.08576537756,499994.25579707103 500116.08576537756,500110.1012210889 500286.2657688021,500110.1012210889 500286.2657688021,499994.25579707103 500116.08576537756,499994.25579707103``
  58. * in application/xml: the following xml
  59. .. code-block:: xml
  60. <?xml version="1.0" encoding="UTF-8"?><gml:Polygon xmlns:gml="http://www.opengis.net/gml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink">
  61. <gml:outerBoundaryIs>
  62. <gml:LinearRing>
  63. <gml:coordinates>500116.08576537756,499994.25579707103 500116.08576537756,500110.1012210889 500286.2657688021,500110.1012210889 500286.2657688021,499994.25579707103 500116.08576537756,499994.25579707103</gml:coordinates>
  64. </gml:LinearRing>
  65. </gml:outerBoundaryIs>
  66. </gml:Polygon>
  67. The general structure of a WPS Download request POST payload consists of two parts: the first (``<wps:DataInputs>``) contains the input parameters for the process, and the second (``<wps:ResponseForm>``) contains details about delivering the output. A typical pseudo payload is the following:
  68. .. code-block:: xml
  69. <?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  70. <ows:Identifier>gs:WPS_Process_Name_Here</ows:Identifier>
  71. <wps:DataInputs>
  72. <wps:Input>
  73. <ows:Identifier>First_Param_Name</ows:Identifier>
  74. <wps:Data>
  75. (First_Param_Data)
  76. </wps:Data>
  77. </wps:Input>
  78. ...
  79. ...
  80. </wps:DataInputs>
  81. <wps:ResponseForm>
  82. <wps:RawDataOutput mimeType="application/zip">
  83. <ows:Identifier>result</ows:Identifier>
  84. </wps:RawDataOutput>
  85. </wps:ResponseForm>
  86. </wps:Execute>
  87. Each parameter for the process is defined in its own ``<wps:Input>`` xml block. In case of simple type data, such as layerName, outputFormat, targetCRS, etc, input params xml blocks have the following form:
  88. .. code-block:: xml
  89. <wps:Input>
  90. <ows:Identifier>layerName</ows:Identifier>
  91. <wps:Data>
  92. <wps:LiteralData>nurc:Img_Sample</wps:LiteralData>
  93. </wps:Data>
  94. </wps:Input>
  95. Note the ``<wps:LiteralData>`` tags wrapping the parameter value.
  96. In case of geometry parameters, such as filter, ROI, the parameter's ``<wps:Input>`` block is different:
  97. .. code-block:: xml
  98. <wps:Input>
  99. <ows:Identifier>ROI</ows:Identifier>
  100. <wps:Data>
  101. <wps:ComplexData mimeType="application/wkt"><![CDATA[POLYGON (( 500116.08576537756 499994.25579707103, 500116.08576537756 500110.1012210889, 500286.2657688021 500110.1012210889, 500286.2657688021 499994.25579707103, 500116.08576537756 499994.25579707103 ))]]></wps:ComplexData>
  102. </wps:Data>
  103. </wps:Input>
  104. Note the ``<wps:ComplexData>`` tag, the ``mimeType="application/wkt"`` parameter, and the ``![CDATA[]`` wrapping of the actual geometry data (in textual representation), according to the selected MIME type.
  105. Note that if the ROI parameter is defined as WKT, you will need to specify a RoiCRS input parameter as well.
  106. In case the ROI is defined using a REFERENCE source, the input block is slightly different:
  107. .. code-block:: xml
  108. <wps:Input>
  109. <ows:Identifier>ROI</ows:Identifier>
  110. <wps:Reference mimeType="application/wkt" xlink:href="url_to_fetch_data" method="GET"/>
  111. </wps:Input>
  112. Note the ``<wps:Reference>`` tag replacing ``<wps:ComplexData>`` tag, and the extra ``xlink:href="url_to_fetch_data"`` parameter, which defines the url to perform the HTTP GET request. For POST request cases, tech method is switched to POST, and a ``<wps:Body>`` tag is used to wrap POST data:
  113. .. code-block:: xml
  114. <wps:Reference mimeType="application/wkt" xlink:href="url_to_fetch_data" method="POST">
  115. <wps:Body><![CDATA[request_body_data]]></wps:Body>
  116. </wps:Reference>
  117. Filter parameter definition
  118. ++++++++++++++++++++++++++++
  119. A ``filter`` parameter is a definition of a vector filter operation:
  120. * as ``TEXT``, in various textual formats/representations
  121. * as ``REFERENCE``, which is the textual result of an HTTP GET/POST request to a specific url
  122. * as a ``SUBPROCESS`` result: the format produced as result of the process execution must be a compatible geometry textual format.
  123. Compatible text formats for filter definitions are:
  124. * ``text/xml; filter/1.0``
  125. * ``text/xml; filter/1.1``
  126. * ``text/xml; cql``
  127. For more details on filter formats/languages, one can see :doc:`../../filter/syntax` and :doc:`../../filter/function`.
  128. Filter parameter applies to vector data. If this is the case with input data, a sample ``<wps:Input>`` block of a filter intersecting the polygon we used earlier as an example for ROI definition would be:
  129. .. code-block:: xml
  130. <wps:Input>
  131. <ows:Identifier>filter</ows:Identifier>
  132. <wps:Data>
  133. <wps:ComplexData mimeType="text/plain; subtype=cql"><![CDATA[<Intersects>
  134. <PropertyName>GEOMETRY</PropertyName>
  135. <gml:Polygon>
  136. <gml:outerBoundaryIs>
  137. <gml:LinearRing>
  138. <gml:coordinates>500116.08576537756,499994.25579707103 500116.08576537756,500110.1012210889 500286.2657688021,500110.1012210889 500286.2657688021,499994.25579707103 500116.08576537756,499994.25579707103</gml:coordinates>
  139. </gml:LinearRing>
  140. </gml:outerBoundaryIs>
  141. </gml:Polygon>
  142. </Intersects>]]></wps:ComplexData>
  143. </wps:Data>
  144. </wps:Input>
  145. Sample request
  146. +++++++++++++++++
  147. Synchronous execution
  148. ^^^^^^^^^^^^^^^^^^^^^
  149. The following is a sample WPS request for processing a raster dataset.
  150. Suppose we want to use the North America sample imagery (**nurc:Img_Sample**) layer, to produce an **80x80** pixels downloadable **tiff** in **EPSG:4326**
  151. Assuming that a local geoserver instance (setup for wps/wps-download support) is running, we issue a POST request to the url:
  152. ``http://127.0.0.1:8080/geoserver/ows?service=wps``
  153. using the following payload:
  154. .. code-block:: xml
  155. <?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  156. <ows:Identifier>gs:Download</ows:Identifier>
  157. <wps:DataInputs>
  158. <wps:Input>
  159. <ows:Identifier>layerName</ows:Identifier>
  160. <wps:Data>
  161. <wps:LiteralData>nurc:Img_Sample</wps:LiteralData>
  162. </wps:Data>
  163. </wps:Input>
  164. <wps:Input>
  165. <ows:Identifier>outputFormat</ows:Identifier>
  166. <wps:Data>
  167. <wps:LiteralData>image/tiff</wps:LiteralData>
  168. </wps:Data>
  169. </wps:Input>
  170. <wps:Input>
  171. <ows:Identifier>targetCRS</ows:Identifier>
  172. <wps:Data>
  173. <wps:LiteralData>EPSG:4326</wps:LiteralData>
  174. </wps:Data>
  175. </wps:Input>
  176. <wps:Input>
  177. <ows:Identifier>targetSizeX</ows:Identifier>
  178. <wps:Data>
  179. <wps:LiteralData>80</wps:LiteralData>
  180. </wps:Data>
  181. </wps:Input>
  182. <wps:Input>
  183. <ows:Identifier>targetSizeY</ows:Identifier>
  184. <wps:Data>
  185. <wps:LiteralData>80</wps:LiteralData>
  186. </wps:Data>
  187. </wps:Input>
  188. </wps:DataInputs>
  189. <wps:ResponseForm>
  190. <wps:RawDataOutput mimeType="application/zip">
  191. <ows:Identifier>result</ows:Identifier>
  192. </wps:RawDataOutput>
  193. </wps:ResponseForm>
  194. </wps:Execute>
  195. More parameters (from the parameter list above) can be used, for example, we can only select bands **0 and 2** from the original raster:
  196. .. code-block:: xml
  197. <wps:Input>
  198. <ows:Identifier>bandIndices</ows:Identifier>
  199. <wps:Data>
  200. <wps:LiteralData>0</wps:LiteralData>
  201. </wps:Data>
  202. </wps:Input>
  203. <wps:Input>
  204. <ows:Identifier>bandIndices</ows:Identifier>
  205. <wps:Data>
  206. <wps:LiteralData>2</wps:LiteralData>
  207. </wps:Data>
  208. </wps:Input>
  209. Or, use a **Region Of Interest** to crop the dataset:
  210. .. code-block:: xml
  211. <wps:Input>
  212. <ows:Identifier>ROI</ows:Identifier>
  213. <wps:Data>
  214. <wps:ComplexData mimeType="application/wkt"><![CDATA["POLYGON (( 500116.08576537756 499994.25579707103, 500116.08576537756 500110.1012210889, 500286.2657688021 500110.1012210889, 500286.2657688021 499994.25579707103, 500116.08576537756 499994.25579707103 ))]]></wps:ComplexData>
  215. </wps:Data>
  216. </wps:Input>
  217. <wps:Input>
  218. <ows:Identifier>RoiCRS</ows:Identifier>
  219. <wps:Data>
  220. <wps:LiteralData>EPSG:32615</wps:LiteralData>
  221. </wps:Data>
  222. </wps:Input>
  223. The result produced is a zipped file to download.
  224. Asynchronous execution
  225. ^^^^^^^^^^^^^^^^^^^^^^
  226. The process can also be performed asynchronously.
  227. In this case, the second part (``wps:ResponseForm``) of the wps download payload slightly changes, by using the **storeExecuteResponse** and **status** parameters, set to **true** for the ``<wps:ResponseDocument>``:
  228. .. code-block:: xml
  229. <wps:ResponseForm>
  230. <wps:ResponseDocument storeExecuteResponse="true" status="true">
  231. <wps:RawDataOutput mimeType="application/zip">
  232. <ows:Identifier>result</ows:Identifier>
  233. </wps:RawDataOutput>
  234. </wps:ResponseDocument>>
  235. </wps:ResponseForm>
  236. In case of asynchronous execution, the initial request to download data returns an xml indication that the process has successfully started:
  237. .. code-block:: xml
  238. <?xml version="1.0" encoding="UTF-8"?><wps:ExecuteResponse xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" service="WPS" serviceInstance="http://127.0.0.1:8080/geoserver/ows?" statusLocation="http://127.0.0.1:8080/geoserver/ows?service=WPS&amp;version=1.0.0&amp;request=GetExecutionStatus&amp;executionId=dd0d61f5-7da3-41ed-bd3f-15311fa660ba" version="1.0.0">
  239. <wps:Process wps:processVersion="1.0.0">
  240. <ows:Identifier>gs:Download</ows:Identifier>
  241. <ows:Title>Enterprise Download Process</ows:Title>
  242. <ows:Abstract>Downloads Layer Stream and provides a ZIP.</ows:Abstract>
  243. </wps:Process>
  244. <wps:Status creationTime="2016-08-08T11:03:18.167Z">
  245. <wps:ProcessAccepted>Process accepted.</wps:ProcessAccepted>
  246. </wps:Status>
  247. </wps:ExecuteResponse>
  248. The response contains a ``<wps:Status>`` block indicating successful process creation and process start time. However, the important part in this response is the **executionId=dd0d61f5-7da3-41ed-bd3f-15311fa660ba** attribute in the ``<wps:ExecuteResponse>`` tag. The ``dd0d61f5-7da3-41ed-bd3f-15311fa660ba`` ID can be used as a reference for this process, in order to issue new GET requests and to check process status. These requests have the form:
  249. ``http://127.0.0.1:8080/geoserver/ows?service=WPS&request=GetExecutionStatus&executionId=277e24eb-365d-42e1-8329-44b8076d4fc0``
  250. When issued (and process has finished on the server), this GET request returns the result to download/process as a base64 encoded zip:
  251. .. code-block:: xml
  252. <?xml version="1.0" encoding="UTF-8"?>
  253. <wps:ExecuteResponse xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" service="WPS" serviceInstance="http://127.0.0.1:8080/geoserver/ows?" statusLocation="http://127.0.0.1:8080/geoserver/ows?service=WPS&amp;version=1.0.0&amp;request=GetExecutionStatus&amp;executionId=0c596a4d-7ddb-4a4e-bf35-4a64b47ee0d3" version="1.0.0">
  254. <wps:Process wps:processVersion="1.0.0">
  255. <ows:Identifier>gs:Download</ows:Identifier>
  256. <ows:Title>Enterprise Download Process</ows:Title>
  257. <ows:Abstract>Downloads Layer Stream and provides a ZIP.</ows:Abstract>
  258. </wps:Process>
  259. <wps:Status creationTime="2016-08-08T11:18:46.015Z">
  260. <wps:ProcessSucceeded>Process succeeded.</wps:ProcessSucceeded>
  261. </wps:Status>
  262. <wps:ProcessOutputs>
  263. <wps:Output>
  264. <ows:Identifier>result</ows:Identifier>
  265. <ows:Title>Zipped output files to download</ows:Title>
  266. <wps:Data>
  267. <wps:ComplexData encoding="base64" mimeType="application/zip">UEsDBBQACAgIAFdyCEkAAAAAAAAAAAAAAAApAAAAMGEwYmJkYmQtMjdkNi00...(more zipped raster data following, ommited for space saving)...</wps:ComplexData>
  268. </wps:Data>
  269. </wps:Output>
  270. </wps:ProcessOutputs>
  271. </wps:ExecuteResponse>
  272. Asynchronous execution (output as a reference)
  273. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  274. The ``<wps:ResponseForm>`` of the previous asynchronous request payload example can be modified to get back a link to the file to be downloaded instead of the base64 encoded data.
  275. .. code-block:: xml
  276. ...
  277. <wps:ResponseForm>
  278. <wps:ResponseDocument storeExecuteResponse="true" status="true">
  279. <wps:Output asReference="true" mimeType="application/zip">
  280. <ows:Identifier>result</ows:Identifier>
  281. </wps:Output>
  282. </wps:ResponseDocument>
  283. </wps:ResponseForm>
  284. Note ``<wps:ResponseDocument>`` contains a ``<wps:Output>`` instead of a ``<wps:RawDataOutput>`` being used by previous example.
  285. Moreover the attribute **asReference** set to **true** has been added to the ``<wps:Output>``.
  286. This time, when issued (and process has finished on the server), the GET request returns the result to download as a link as part of ``<wps:Output><wps:Reference>`` .
  287. .. code-block:: xml
  288. <?xml version="1.0" encoding="UTF-8"?>
  289. <wps:ExecuteResponse xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" service="WPS" serviceInstance="http://127.0.0.1:8080/geoserver/ows?" statusLocation="http://127.0.0.1:8080/geoserver/ows?service=WPS&amp;version=1.0.0&amp;request=GetExecutionStatus&amp;executionId=c1074100-446a-4963-94ad-cbbf8b8a7fd1" version="1.0.0">
  290. <wps:Process wps:processVersion="1.0.0">
  291. <ows:Identifier>gs:Download</ows:Identifier>
  292. <ows:Title>Enterprise Download Process</ows:Title>
  293. <ows:Abstract>Downloads Layer Stream and provides a ZIP.</ows:Abstract>
  294. </wps:Process>
  295. <wps:Status creationTime="2016-08-08T11:38:34.024Z">
  296. <wps:ProcessSucceeded>Process succeeded.</wps:ProcessSucceeded>
  297. </wps:Status>
  298. <wps:ProcessOutputs>
  299. <wps:Output>
  300. <ows:Identifier>result</ows:Identifier>
  301. <ows:Title>Zipped output files to download</ows:Title>
  302. <wps:Reference href="http://127.0.0.1:8080/geoserver/ows?service=WPS&amp;version=1.0.0&amp;request=GetExecutionResult&amp;executionId=c1074100-446a-4963-94ad-cbbf8b8a7fd1&amp;outputId=result.zip&amp;mimetype=application%2Fzip" mimeType="application/zip" />
  303. </wps:Output>
  304. </wps:ProcessOutputs>
  305. </wps:ExecuteResponse>
  306. Output Format and Response mime-types
  307. +++++++++++++++++++++++++++++++++++++
  308. By default, downloading vector data results in a Shapefile, compressed in a zip file along with
  309. its SLD file. It's also possible to download a GeoPackage file using ``application/geopackage+sqlite3``
  310. as the value for the ``mimeType`` parameter.
  311. Similarly, for raster data, by default the downloaded raster gets zipped, along with the SLD style associated to the layer.
  312. In some cases, this can be unnecessary, especially if the output TIFF already has some type of internal compression or if we simply want to get back the TIFF output file without the ancillary SLD. Let's consider downloading a RGB TIFF: the default raster.sld style won't add anything useful to the output. In that case it's possible to specify ``image/tiff`` in the Response's output ``mimeType``: the output TIFF will be provided as is, without extra steps of compression and file management.
  313. .. code-block:: xml
  314. ...
  315. <wps:ResponseForm>
  316. <wps:ResponseDocument storeExecuteResponse="true" status="true">
  317. <wps:Output asReference="true" mimeType="image/tiff">
  318. <ows:Identifier>result</ows:Identifier>
  319. </wps:Output>
  320. </wps:ResponseDocument>
  321. </wps:ResponseForm>
  322. It is also possible to download the raster data as a GeoPackage, using ``application/geopackage+sqlite3``
  323. as the value for the ``mimeType`` parameter.
  324. Writing buffering options
  325. +++++++++++++++++++++++++
  326. By default raster pixels are encoded using a file stream writing through a default 16KB data buffer.
  327. Depending on the network and disk setup, you might want to change the size of the buffer to improve performance. This can be done by adding this property to the ``JAVA_OPTS``: ``-Dorg.geoserver.wps.download.raster.buffer.size=sizeinbytes`` where ``sizeinbytes`` is the actual value to be set, i.e. 1048576 to set a 1MB buffer.
  328. Moreover, when copying back data resources from within the WPS machinery to the final file output location, a default 16KB data buffer is being used.
  329. It's also possible to change the size of such buffer by adding this property to the ``JAVA_OPTS``: ``-Dorg.geoserver.wps.copy.buffer.size=sizeinbytes`` where ``sizeinbytes`` is the actual value to be set, i.e. 1048576 to set a 1MB buffer.
  330. .. _writing_params:
  331. Writing parameters
  332. ++++++++++++++++++
  333. The ``writeParameters`` input element of a process execution allows to specify parameters to be applied by the ``outputFormat`` encoder when producing the output file.
  334. Writing parameters are listed as multiple ``<dwn:Parameter key="writingParameterName">value</dwn:Parameter>`` within a ``<dwn:Parameters>`` parent element.
  335. See the below xml containing full syntax of a valid example for TIFF output format:
  336. .. code-block:: xml
  337. <wps:Input>
  338. <ows:Identifier>writeParameters</ows:Identifier>
  339. <wps:Data>
  340. <wps:ComplexData xmlns:dwn="http://geoserver.org/wps/download">
  341. <dwn:Parameters>
  342. <dwn:Parameter key="tilewidth">128</dwn:Parameter>
  343. <dwn:Parameter key="tileheight">128</dwn:Parameter>
  344. <dwn:Parameter key="compression">JPEG</dwn:Parameter>
  345. <dwn:Parameter key="quality">0.75</dwn:Parameter>
  346. </dwn:Parameters>
  347. </wps:ComplexData>
  348. </wps:Data>
  349. </wps:Input>
  350. GeoTIFF/TIFF supported writing parameters
  351. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  352. The supported writing parameters are:
  353. * ``tilewidth`` : Width of internal tiles, in pixels
  354. * ``tileheight`` : Height of internal tiles, in pixels
  355. * ``compression`` : Compression type used to store internal tiles. Supported values are:
  356. * ``CCITT RLE`` (Lossless) (Huffman)
  357. * ``LZW`` (Lossless)
  358. * ``JPEG`` (Lossy)
  359. * ``ZLib`` (Lossless)
  360. * ``PackBits`` (Lossless)
  361. * ``Deflate`` (Lossless)
  362. * ``quality`` : Compression quality. Value is in the range [0 : 1]
  363. * for ``JPEG`` lossy compression, 0 is for worst quality/higher compression and 1 is for best quality/lower compression. (default is 1).
  364. * for ``Deflate`` lossless compression, input value in the range [0 : 1] is linearly mapped to output deflate level in the range [1 : 9]: ``(deflate level = 1 + 8 * (quality))``, where level 1 is for best speed and level 9 is for best compression. (default level is 9)
  365. * ``writenodata`` : Supported value is one of true/false. Note that, by default, a `nodata TAG <https://www.awaresystems.be/imaging/tiff/tifftags/gdal_nodata.html>`_ is produced as part of the output GeoTIFF file as soon as a nodata is found in the GridCoverage2D to be written. Therefore, not specifying this parameter will result into writing nodata to preserve default behavior. Setting it to false will avoid writing that TAG.
  366. Direct download
  367. ---------------
  368. The raster process does its best to identify downloads that are in fact selecting a single, complete
  369. source file, and will perform a straight copy of it in such case.
  370. Conditions:
  371. * A single, complete source file is selected by the request (e.g. full input GeoTIFF, or single
  372. full granule out of an image mosaic).
  373. * The output format matches the input (e.g. both GeoTIFF)
  374. * The write parameters, if present, match the structure of the input file (same compression, same tiling structure)
  375. In order to better support opportunities for direct download, it's possible to specify the write
  376. parameter ``compression`` as ``auto``: it won't interfere with selection of a direct download,
  377. if possible, and will fall back to ``deflate`` in case the direct download is not possible.
  378. .. _heterogeneous_imagemosaic:
  379. RasterDownload of Heterogeneous CRS ImageMosaic
  380. +++++++++++++++++++++++++++++++++++++++++++++++
  381. An ImageMosaic made of granules in different coordinate reference systems (i.e. several DEM files in different UTM zones) is defined as ImageMosaic with Heterogeneous CRS. The ImageMosaic layer will expose a common CRS as the native one (i.e. 4326).
  382. By default, mosaicking granules with different CRSs will result into a reprojection from the original CRS of the granules to that common CRS.
  383. Since 2.17, a new parameter has been defined: ``minimizeReprojections``
  384. It will be used on Raster Download with a defined ROI and a TargetCRS being specified. When set to true, any Granule in the ROI having a nativeCRS matching the TargetCRS will not be affected by reprojection.
  385. Since 2.17, a new parameter has been defined: ``bestResolutionOnMatchingCRS``
  386. It will be used when ``minimizeReprojections`` is enabled too, on Raster Download with a defined ROI and a TargetCRS, without target size being specified.
  387. When set to true, the download will aim to preserve the native properties of the underlying granules matching the targetCRS, as much as possible.
  388. Back to the example, a RasterDownload specifying UTM32N as TargetCRS and a ROI covering an area containing UTM32N granules will result into getting those UTM32N granules without applying any intermediate reprojection, also providing back best raw resolution available for that CRS. So, if the ImageMosaic is a mix of UTM32N DEMs at 10 km resolution and UTM33N at 100 m resolution, the underlying reading request will use 10 km resolution, being the best resolution available in the targetCRS. When no granules are matching the targetCRS, the best resolution is taken from all the granules.
  389. Make sure to configure the ImageMosaic's index to contain both crs and resolution attributes, in order to preserve as much as possible the native properties of the granules.
  390. A typical :file:`indexer.properties` of such ImageMosaic will look like this::
  391. GranuleAcceptors=org.geotools.gce.imagemosaic.acceptors.HeterogeneousCRSAcceptorFactory
  392. GranuleHandler=org.geotools.gce.imagemosaic.granulehandler.ReprojectingGranuleHandlerFactory
  393. HeterogeneousCRS=true
  394. MosaicCRS=EPSG\:XXXX
  395. Schema=*the_geom:Polygon,location:String,crs:String,resX:double,resY:double
  396. ResolutionXAttribute=resX
  397. ResolutionYAttribute=resY
  398. CrsAttribute=crs
  399. PropertyCollectors=CRSExtractorSPI(crs),ResolutionXExtractorSPI(resX),ResolutionYExtractorSPI(resY)
  400. .. _vertical_resampling:
  401. Vertical data resampling on download
  402. ++++++++++++++++++++++++++++++++++++
  403. Coverages containing elevations data (i.e. DTM/DEM/DSM) have pixel values representing elevations/heights referred to a specific VerticalCRS.
  404. The associated VerticalCRS can be specified in the layer configuration, at the very bottom of the page, where a new optional Vertical Coordinate Reference System section shows up.
  405. The following example shows a DSM layer being configured to specify EPSG:5778 as adopted VerticalCRS.
  406. .. figure:: images/verticalCRS.png
  407. :align: center
  408. This section will only show up if:
  409. * The wps-download module has been deployed in GeoServer
  410. * The underlying data is single-band and datatype is at least 16 bit. (i.e.: no Byte datatype, no RGB images, ...)
  411. WPS Download - Vertical resampling
  412. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  413. Resampling the data to a different VerticalCRS as part of the Raster Download Process is possible by specifying the **targetVerticalCRS** parameter in the WPS Download request. For example:
  414. .. code-block:: xml
  415. <wps:Input>
  416. <ows:Identifier>targetVerticalCRS</ows:Identifier>
  417. <wps:Data>
  418. <wps:LiteralData>EPSG:9274</wps:LiteralData>
  419. </wps:Data>
  420. </wps:Input>
  421. .. note::
  422. An exception will be thrown when specifying a targetVerticalCRS but no source VerticalCRS has been assigned to the requested layer through the above setting.
  423. Custom VerticalCRS definitions and grid transformations
  424. ```````````````````````````````````````````````````````
  425. Custom verticalCRS definitions can be specified in GeoServer via properties file as any other Coordinate Reference System, as explained in :ref:`Custom CRS Definitions <crs_custom>` page.
  426. This is an example of the above VerticalCRS being added as a WKT in the :file:`user_projections/epsg.properties` file::
  427. 9274=VERT_CS["EVRF2000 Austria height", \
  428. VERT_DATUM["European Vertical Reference Frame 2000 Austria", \
  429. 2000, AUTHORITY["EPSG","1261"]], \
  430. AXIS["gravity-related height (H)",up], \
  431. UNIT["m",1.0], \
  432. AUTHORITY["EPSG","9274"]]
  433. Transformations between VerticalCRSs can be supported through Vertical Grid Offset files (similarly to how NTV2 Grid Shift can be used in support of 2D grid transformation).
  434. Custom Coordinate Operations are defined in :file:`user_projections/epsg_operations.properties` file within the data directory (create it if it doesn't exist).
  435. Each line in :file:`epsg_operations.properties` will describe a coordinate operation consisting of a `source CRS`, a `target CRS`, and a math transform with its parameter values. Use the following syntax::
  436. <source crs code>,<target crs code>=<WKT math transform>
  437. The Math Transform is a ``Vertical Offset by Grid Interpolation`` requiring 2 parameters:
  438. #. A ``Vertical offset file`` referring an offset file containing a vertical offset for each pixel of the grid. The referred file need to be available in the :file:`user_projections` directory,
  439. #. An ``Interpolation CRS code`` containing the EPSG code of the 2D CoordinateReferenceSystem of the grid file.
  440. Example
  441. ```````
  442. Custom Vertical Grid Shift file for the transformation between the above Vertical CRSs ::
  443. 5778,9274=PARAM_MT["Vertical Offset by Grid Interpolation", \
  444. PARAMETER["Vertical offset file", "GV_Hoehengrid_V1.tif"], \
  445. PARAMETER["Interpolation CRS code", 4312]]
  446. .. note::
  447. Only GeoTIFF vertical offset files are supported at the moment. Vertical resampling will access pixels from that GeoTIFF using tiled loading. Therefore, make sure that the grid file is not striped (a gdalinfo call reporting ``Band 1 Block = NNN x 1`` means a striped file. In that case, consider retiling it for better access before using it as a Vertical Offset File)