Saturday, 3 October 2015

georeferencing - Geoserver: Georectification via SLD fails


Situation


I have a raster image and the coordinates of its four corner pixels. My goal is to warp the image with respect to this coordinates ("georectify") on the fly when requested via GeoServer to display in OpenLayers.


Inspired by this discussion list, my idea was to do the following in GeoServer:



  1. Create a WorldImage layer (raster + text file with geodata)

  2. Create a Styled Layer Descriptor (SLD) calling the Web Processing Service (WPS) GeorectifyCoverage which "georectifies a raster via Ground Control Points using gdal_warp".


  3. Apply the SLD to the layer.


Problem


When I request the layer for example via the OpenLayers preview, it throws an error reporting:


Could not convert the value EPSG:32632 into the expected type interface
org.opengis.referencing.crs.CoordinateReferenceSystem for parameter targetCRS

Oddly enough, when I use the "WPS request builder" (in the GeoServer Web Application) to call GeorectifyCoverage with the same parameters, it gives the right output. So the error must originate somewhere from my SLD document below.


Can anybody give me a clue what might be wrong with it?





Additional Info


SLD document calling WPS rendering transformation GeorectifyCoverage:





GeorectifyCoverage

Georectify Coverage
Warps image to specified GCP





data


gcp
[[[0, 0], [308639.500, 5154180.500]], [[0, 450], [308639.500, 5150929.500]], [[600, 0], [315730.500, 5154180.500]], [[600, 450], [315730.500, 5150929.500]]]



targetCRS
EPSG:32632





1.0








where GeorectifyCoverage requires the following input:



  • data: input raster (my layer name)

  • gcp: List of Ground control points (my corner coordinates)

  • targetCRS: system to use for the output raster (my CRS corresponding to the GCP)



Notes:



  • When I call a different WPS function like Contour using the same document structure and raster image it works perfectly.

  • When I change EPSG:32632 to EPSG:4326 the same error is reported.

  • Changing the raster format (jpeg, TIFF) does not helo.

  • Processing the same data offline with the command line tools gdal_translate (assign GCPs) and gdalwarp results in the desired output.


My System:




  • Ubuntu 12.04

  • OpenGeo Suite 3.0.2

  • GeoServer 2.2


Alternative approaches using OpenGeo would also be welcome.



Answer



I asked the same on the GeoServer User mailing list and the GeoSolutions founder Simone Giannecchini himself suggested me the following workaround:


Instead of specifying the input parameter targetCRS as a , one could pass it to the function via a WMS request. This can be achieved using Variable substitution in SLD, i.e., defining targetCRS in the SLD (here called georectify) as a env request parameter (here wms_crs)



targetCRS


wms_crs



and then pass down the actual value (EPSG:32632) through a WMS request like in


.../wms?LAYERS=myworkspace:mylayer&STYLES:georectify&ENV=wms_crs:EPSG:32632&...

We tried that out and it worked.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...