error in reading image using R script

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

error in reading image using R script

soshi
Hi dear all,
I'm going to write a process using R and get request from wps client.
but it got error;

R script:

#wps.des: GetRaster, test image process;
#wps.in: input,image/geotiff;


library(raster);

x = raster(input);

f = writeRaster(temp, filename="x.tif", overwrite=TRUE);


output = "x.tif"

#wps.out: output, image/geotiff;

request :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wps:Execute service="WPS" version="1.0.0"
        xmlns:wps="http://www.opengis.net/wps/1.0.0"
        xmlns:ows="http://www.opengis.net/ows/1.1"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0
  http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
        <ows:Identifier>org.n52.wps.server.r.GetRaster</ows:Identifier>
        <wps:DataInputs>
                <wps:Input>
                        <ows:Identifier
                                xmlns:ns1="http://www.opengis.net/ows/1.1">input
                       
                       
                        </ows:Identifier>
                        <wps:Reference xlink:href="http://localhost:8080/jask.tif" mimeType="image/geotiff" />
                </wps:Input>
        </wps:DataInputs>
        <wps:ResponseForm>
                <wps:RawDataOutput mimeType="image/geotiff">
                        <ows:Identifier>output</ows:Identifier>
                </wps:RawDataOutput>
        </wps:ResponseForm>
</wps:Execute> 

and execute response get error:
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" version="1.0.0">
<ows:Exception exceptionCode="InvalidParameterValue" locator="input identifier">
<ows:ExceptionText>Input Identifier is not valid: input</ows:ExceptionText>
</ows:Exception>
<ows:Exception exceptionCode="JAVA_StackTrace">
<ows:ExceptionText>
org.n52.wps.server.ExceptionReport: Input Identifier is not valid: input at org.n52.wps.server.request.ExecuteRequest.validate(ExecuteRequest.java:622) at org.n52.wps.server.request.ExecuteRequest.<init>(ExecuteRequest.java:125) at org.n52.wps.server.handler.RequestHandler.<init>(RequestHandler.java:253) at org.n52.wps.server.WebProcessingService.doPost(WebProcessingService.java:331) at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) at org.n52.wps.server.WebProcessingService.service(WebProcessingService.java:362) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:410) at org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:169) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:169) at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:232) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1096) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:760) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1480) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)
</ows:ExceptionText>
</ows:Exception>
<ows:Exception exceptionCode="JAVA_RootCause"/>
</ows:ExceptionReport>

any ideas?
 
Reply | Threaded
Open this post in threaded view
|

Re: error in reading image using R script

BenjaminPross
Try changing the script to this (replace image/geotiff with just geotiff):

#wps.des: GetRaster, test image process;
#wps.in: input, geotiff;

library(raster);

x = raster(input);

f = writeRaster(temp, filename="x.tif", overwrite=TRUE);

output = "x.tif"

#wps.out: output, geotiff;

Then the request should look like this (make sure that there are no blanks or tabs before or after the input identifier, change the mimeType to application/geotiff):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wps:Execute service="WPS" version="1.0.0"
        xmlns:wps="http://www.opengis.net/wps/1.0.0"
        xmlns:ows="http://www.opengis.net/ows/1.1"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0
  http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
        <ows:Identifier>org.n52.wps.server.r.GetRaster</ows:Identifier>
        <wps:DataInputs>
                <wps:Input>
                        <ows:Identifier
                                xmlns:ns1="http://www.opengis.net/ows/1.1">input</ows:Identifier>
                        <wps:Reference xlink:href="http://localhost:8080/jask.tif" mimeType="application/geotiff" />
                </wps:Input>
        </wps:DataInputs>
        <wps:ResponseForm>
                <wps:RawDataOutput mimeType="application/geotiff">
                        <ows:Identifier>output</ows:Identifier>
                </wps:RawDataOutput>
        </wps:ResponseForm>
</wps:Execute>
Reply | Threaded
Open this post in threaded view
|

Re: error in reading image using R script

soshi
it works..
Thank you so much...
Reply | Threaded
Open this post in threaded view
|

Re: error in reading image using R script

soshi
another question:
I get image using wcs (Get Coverage request ) from geoserver (image saved in geoserver). but it got error:

request:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wps:Execute service="WPS" version="1.0.0"
        xmlns:wps="http://www.opengis.net/wps/1.0.0"
        xmlns:ows="http://www.opengis.net/ows/1.1"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0
  http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
        <ows:Identifier>org.n52.wps.server.r.GetRaster</ows:Identifier>
        <wps:DataInputs>
                <wps:Input>
                    <ows:Identifier>input</ows:Identifier>
                                        <wps:Reference xlink:href="http://localhost:8080/geoserver/wcs" mimeType="application/geotiff">
                                                <wps:Body>
                                                        <GetCoverage version="1.0.0" service="WCS"
                                                                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                                                xmlns="http://www.opengis.net/wcs"
                                                                xmlns:ows="http://www.opengis.net/ows/1.1"
                                                                xmlns:gml="http://www.opengis.net/gml"
                                                                xmlns:ogc="http://www.opengis.net/ogc" xsi:schemaLocation="http://www.opengis.net/wcs http://schemas.opengis.net/wcs/1.0.0/getCoverage.xsd">
                                                                <sourceCoverage>satellite_Image:jask</sourceCoverage>
                                                                          <domainSubset>
                                                                                <spatialSubset>
                                                                                  <gml:Envelope srsName="EPSG:4326">
                                                                                        <gml:pos>57.75787353515625 25.62914524750722</gml:pos>
                                                                                        <gml:pos>57.83752675448401 25.67618668252546</gml:pos>
                                                                                  </gml:Envelope>
                                                                                  <gml:Grid dimension="2">
                                                                                        <gml:limits>
                                                                                          <gml:GridEnvelope>
                                                                                                <gml:low>0 0</gml:low>
                                                                                                <gml:high>8236 4864</gml:high>
                                                                                          </gml:GridEnvelope>
                                                                                        </gml:limits>
                                                                                        <gml:axisName>x</gml:axisName>
                                                                                        <gml:axisName>y</gml:axisName>
                                                                                  </gml:Grid>
                                                                                </spatialSubset>
                                                                          </domainSubset>
                                                                <output>
                                                                        <crs>EPSG:4326</crs>
                                                                        <format>GeoTIFF</format>
                                                                </output>
                                                        </GetCoverage>
                                                </wps:Body>
                                        </wps:Reference>
                </wps:Input>
          <wps:Input>
                <ows:Identifier>wavelength</ows:Identifier>
                <wps:Data>
                  <wps:LiteralData dataType="xs:double">3.964</wps:LiteralData>
                </wps:Data>
          </wps:Input>
        </wps:DataInputs>
        <wps:ResponseForm>
                <wps:RawDataOutput mimeType="application/geotiff">
                        <ows:Identifier>output</ows:Identifier>
                </wps:RawDataOutput>
        </wps:ResponseForm>
</wps:Execute>


and response:

<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" version="1.0.0">
<ows:Exception exceptionCode="RemoteComputationError">
<ows:ExceptionText>
An R error occured while executing R script: Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file.
</ows:ExceptionText>
</ows:Exception>
<ows:Exception exceptionCode="JAVA_StackTrace">
<ows:ExceptionText>
org.n52.wps.server.ExceptionReport: An R error occured while executing R script: Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file. at org.n52.wps.server.r.util.RExecutor.executeScript(RExecutor.java:191) at org.n52.wps.server.r.GenericRProcess.run(GenericRProcess.java:242) at org.n52.wps.server.request.ExecuteRequest.call(ExecuteRequest.java:685) at org.n52.wps.server.request.ExecuteRequest.call(ExecuteRequest.java:92) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
</ows:ExceptionText>
</ows:Exception>
<ows:Exception exceptionCode="JAVA_RootCause"/>
</ows:ExceptionReport>

how can I resolve that?
Reply | Threaded
Open this post in threaded view
|

Re: error in reading image using R script

soshi
geoserver got error in getCoverage request (satellite_Image:jask):

<?xml version="1.0" encoding="UTF-8"?><ServiceExceptionReport version="1.2.0" >   <ServiceException>
      javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found
Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found
org/apache/xerces/jaxp/DocumentBuilderFactoryImpl
</ServiceException></ServiceExceptionReport>
Reply | Threaded
Open this post in threaded view
|

Re: error in reading image using R script

BenjaminPross
If you are using the WPS and GeoServer in the same Tomcat instance, you will need to copy the file %wps%\WEB-INF\lib\xercesImpl-2.7.1.jar to %tomcat%\lib
Reply | Threaded
Open this post in threaded view
|

Re: error in reading image using R script

soshi
It works...., thank you so much