Error in rgeos

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

Error in rgeos

sammeek
Hi Board,

When using spatial files with the R backend I get the following error:


NoApplicableCode
Error while executing the embedded process for: org.n52.wps.server.r.intersection2
JAVA_StackTrace
org.n52.wps.server.request.ExecuteRequest.call:668 org.n52.wps.server.request.ExecuteRequest.call:91 java.util.concurrent.FutureTask$Sync.innerRun:334 java.util.concurrent.FutureTask.run:166 java.util.concurrent.ThreadPoolExecutor.runWorker:1146 java.util.concurrent.ThreadPoolExecutor$Worker.run:615 java.lang.Thread.run:701
JAVA_RootCause
An R-error occured while executing R-script: Error in library("rgeos") : there is no package called ‘rgeos’

As you can see, I am just trying to execute an intersection with the following script:


# wps.des: org.n52.wps.server.r.intersection2;
# wps.in: r1, shp_x, Polygon1;
# wps.in: r2, shp_x, Polygon2;
library("rgeos"); library("maptools"); library("rgdal");

poly1 = readShapePoly(r1)
poly2 = readShapePoly(r2)

polyint = gIntersection(poly1,poly2)

poly = as(polyint,"SpatialPolygonsDataFrame")

out="out.shp"
writeOGR(poly, out, "data","ESRI Shapefile")

# wps.out: out, shp, Intersection Polygon;

Any idea why this is happening?

Sam
Reply | Threaded
Open this post in threaded view
|

Re: Error in rgeos

Daniel
Am 03.07.2014 15:40, schrieb sammeek:
> Hi Board,
> When using spatial files with the R backend I get the following error:
NoApplicableCode

> Error while executing the embedded process for:
> org.n52.wps.server.r.intersection2
> JAVA_StackTrace
> org.n52.wps.server.request.ExecuteRequest.call:668
> org.n52.wps.server.request.ExecuteRequest.call:91
> java.util.concurrent.FutureTask$Sync.innerRun:334
> java.util.concurrent.FutureTask.run:166
> java.util.concurrent.ThreadPoolExecutor.runWorker:1146
> java.util.concurrent.ThreadPoolExecutor$Worker.run:615
> java.lang.Thread.run:701
> JAVA_RootCause
> An R-error occured while executing R-script: Error in library("rgeos") :
there is no package called ‘rgeos’

Did you install the package beforehand?

install.packages("rgeos");


Can you run the script when you start your regular R _on the command line_?



/Daniel

> As you can see, I am just trying to execute an intersection with the
following script:

> # wps.des: org.n52.wps.server.r.intersection2;
> # wps.in: r1, shp_x, Polygon1;
> # wps.in: r2, shp_x, Polygon2;
> library("rgeos"); library("maptools"); library("rgdal");
> poly1 = readShapePoly(r1)
> poly2 = readShapePoly(r2)
> polyint = gIntersection(poly1,poly2)
> poly = as(polyint,"SpatialPolygonsDataFrame")
> out="out.shp"
> writeOGR(poly, out, "data","ESRI Shapefile")
> # wps.out: out, shp, Intersection Polygon;
> Any idea why this is happening?
> Sam
> --
> View this message in context:
http://geoprocessing.forum.52north.org/Error-in-rgeos-tp4025662.html
> Sent from the 52° North - Geoprocessing Community Forum mailing list
archive at Nabble.com.
> _______________________________________________
> Geoprocessingservices mailing list
> [hidden email]
> http://list.52north.org/mailman/listinfo/geoprocessingservices
> http://geoprocessing.forum.52north.org


--
Daniel NÃŒst
52°North Initiative for Geospatial Open Source Software GmbH
Martin-Luther-King-Weg 24
48155 MÃŒnster, Germany
E-Mail: [hidden email]
Fon: +49-(0)-251–396371-36
Fax: +49-(0)-251–396371-11

http://52north.org/
Twitter: @FiveTwoN

General Managers: Dr. Albert Remke, Dr. Andreas Wytzisk
Local Court Muenster HRB 10849




_______________________________________________
Geoprocessingservices mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geoprocessingservices
http://geoprocessing.forum.52north.org
Reply | Threaded
Open this post in threaded view
|

Re: Error in rgeos

sammeek
Hi Daniel,

I can indeed run the script in command line without using the WPS. The package rgeos isn't actually the issue as it happens whenever a script runs a "library()" import:

# wps.des: org.n52.wps.server.r.Sum2, title = Sum of attributes for Polygons, abstract = Calculates the sum of a numeric
# attribute variable for given Polygon files;
# given by execute request: variables with identifiers "data" and "attributename";
# wps.in: data, application/x-zipped-shp;
# wps.in: attributename, string;
library ( "maptools" ); library ( "sp" ); <---this line
input=readShapePoly(data)
sum = sum(input@data[attributename])

#other output functions may be:
#mean = mean(input@data[attributename])
#median = median((input@data[attribute])[!is.na(input@data[attributname])])
#max = max(input@data[attributename])
#min = min(input@data[attributename])
#quList = quantile(input@data[attributename], probs = seq(0, 1, 0.25), na.rm=T)

#output variable - shall be always named "result":
result = sum
# wps.out: result, double;


Is there something going wrong with the encoding maybe?

Thanks

Sam
Reply | Threaded
Open this post in threaded view
|

Re: Error in rgeos

Daniel
Hi Sam,

can you please run sessionInfo() in the console where the script works
and post the session info from a WPS4R process?

You can use any of the test processes for that, just also query the
SessionInfo output parameter.

I suspect that a different user is used for the execution of the WPS
which does not have access to the local extension package repository.

/Daniel

Am 04.07.2014 10:06, schrieb sammeek:

> Hi Daniel,
>
> I can indeed run the script in command line without using the WPS. The
> package rgeos isn't actually the issue as it happens whenever a script runs
> a "library()" import:
>
> # wps.des: org.n52.wps.server.r.Sum2, title = Sum of attributes for
> Polygons, abstract = Calculates the sum of a numeric
> # attribute variable for given Polygon files;
> # given by execute request: variables with identifiers "data" and
> "attributename";
> # wps.in: data, application/x-zipped-shp;
> # wps.in: attributename, string;
> library ( "maptools" ); library ( "sp" ); *<---this line*
> input=readShapePoly(data)
> sum = sum(input@data[attributename])
>
> #other output functions may be:
> #mean = mean(input@data[attributename])
> #median = median((input@data[attribute])[!is.na(input@data[attributname])])
> #max = max(input@data[attributename])
> #min = min(input@data[attributename])
> #quList = quantile(input@data[attributename], probs = seq(0, 1, 0.25),
> na.rm=T)
>
> #output variable - shall be always named "result":
> result = sum
> # wps.out: result, double;
>
>
> Is there something going wrong with the encoding maybe?
>
> Thanks
>
> Sam
>
>
>
> --
> View this message in context: http://geoprocessing.forum.52north.org/Error-in-rgeos-tp4025662p4025667.html
> Sent from the 52° North - Geoprocessing Community Forum mailing list archive at Nabble.com.
> _______________________________________________
> Geoprocessingservices mailing list
> [hidden email]
> http://list.52north.org/mailman/listinfo/geoprocessingservices
> http://geoprocessing.forum.52north.org
>


--
Daniel Nüst
52°North Initiative for Geospatial Open Source Software GmbH
Martin-Luther-King-Weg 24
48155 Münster, Germany
E-Mail: [hidden email]
Fon: +49-(0)-251–396371-36
Fax: +49-(0)-251–396371-11

http://52north.org/
Twitter: @FiveTwoN

General Managers: Dr. Albert Remke, Dr. Andreas Wytzisk
Local Court Muenster HRB 10849
_______________________________________________
Geoprocessingservices mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geoprocessingservices
http://geoprocessing.forum.52north.org
Reply | Threaded
Open this post in threaded view
|

Re: Error in rgeos

sammeek
Hi Daniel,

Working sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8  
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C      

attached base packages:
[1] datasets  utils     grDevices graphics  stats     methods   base    

other attached packages:
[1] rgeos_0.3-5     automap_1.0-14  maptools_0.8-30 spatstat_1.37-0
[5] rgdal_0.8-16    gstat_1.0-19    sp_1.0-15      

loaded via a namespace (and not attached):
 [1] abind_1.4-0      deldir_0.1-5     FNN_1.1          foreign_0.8-61  
 [5] grid_3.1.0       intervals_0.14.0 lattice_0.20-29  Matrix_1.1-4    
 [9] mgcv_1.8-0       nlme_3.1-117     plyr_1.8.1       polyclip_1.3-0  
[13] Rcpp_0.11.2      reshape_0.8.5    spacetime_1.1-0  tensor_1.5      
[17] xts_0.9-7        zoo_1.7-11      
>


Not working:

R version 3.1.0 (2014-04-10)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8  
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C      

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

It is as you suspect, the packages are not loaded. How do I sort this? I have setup Rprofile.site as instructed.

Sam
Reply | Threaded
Open this post in threaded view
|

Re: Error in rgeos

sammeek
Hi Daniel,

Have you managed to have a look at this yet? I'm sure its something simple, but I cannot find the problem.

Thanks

Sam
Reply | Threaded
Open this post in threaded view
|

Re: Error in rgeos

Daniel
In reply to this post by sammeek
Am 04.07.2014 15:44, schrieb sammeek:

> Hi Daniel,
>
> Working sessionInfo()
> R version 3.1.0 (2014-04-10)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
>  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
>  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8  
>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
> [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C      
>
> attached base packages:
> [1] datasets  utils     grDevices graphics  stats     methods   base    
>
> other attached packages:
> [1] rgeos_0.3-5     automap_1.0-14  maptools_0.8-30 spatstat_1.37-0
> [5] rgdal_0.8-16    gstat_1.0-19    sp_1.0-15      
>
> loaded via a namespace (and not attached):
>  [1] abind_1.4-0      deldir_0.1-5     FNN_1.1          foreign_0.8-61  
>  [5] grid_3.1.0       intervals_0.14.0 lattice_0.20-29  Matrix_1.1-4    
>  [9] mgcv_1.8-0       nlme_3.1-117     plyr_1.8.1       polyclip_1.3-0  
> [13] Rcpp_0.11.2      reshape_0.8.5    spacetime_1.1-0  tensor_1.5      
> [17] xts_0.9-7        zoo_1.7-11      
>>
>
>
> Not working:
>
> R version 3.1.0 (2014-04-10)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
>  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
>  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8  
>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
> [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C      
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base    
>
> It is as you suspect, the packages are not loaded. How do I sort this? I
> have setup Rprofile.site as instructed.

Print the current/default library location for both the working and the
not-working environment (probably will have to capture the output of
WPS4R), see
http://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html

Run in both environments the commands

.Library
.Library.site
.libPaths()
Sys.getenv("USERNAME")
Sys.getenv("USER")


And post the outputs here.

/Daniel


--
Daniel Nüst
52°North Initiative for Geospatial Open Source Software GmbH
Martin-Luther-King-Weg 24
48155 Münster, Germany
E-Mail: [hidden email]
Fon: +49-(0)-251–396371-36
Fax: +49-(0)-251–396371-11

http://52north.org/
Twitter: @FiveTwoN

General Managers: Dr. Albert Remke, Dr. Andreas Wytzisk
Local Court Muenster HRB 10849
_______________________________________________
Geoprocessingservices mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geoprocessingservices
http://geoprocessing.forum.52north.org
Reply | Threaded
Open this post in threaded view
|

Re: Error in rgeos

Daniel
Hi Sam,

could you try my suggestions?

/Daniel