On Thu, 7 Apr 2016, Stachelek, Joseph wrote:
Hello,
I am trying to call "maptools::unionSpatialPolygons()" from the
command-line. To illustrate the problem, I can call
example(unionSpatialPolygons) from an interactive session but running
an R script (testmaptools.R) containing:
`library(maptools)`
`example(unionSpatialPolygons)`
With R --vanilla < testmaptools.R
and adding print(sessionInfo()) to the script, we see:
attached base packages:
[1] stats graphics grDevices utils datasets methods base
and it runs correctly. With
Rscript testmaptools.R
we see:
attached base packages:
[1] stats graphics grDevices utils datasets base
The script runs using Rscript if library(methods) is added as the first
line. This issue has been seen elsewhere recently in another context, we
don't know why.
Hope this clarifies,
Roger
yields:
`$ Rscript testmaptools.R`
WARNING: ignoring environment value of R_HOME
Loading required package: sp
Checking rgeos availability: TRUE
unnSpP> if (rgeosStatus()) {
unnSpP+ nc1 <- readShapePoly(system.file("shapes/sids.shp",
package="maptools")[1],
unnSpP+ proj4string=CRS("+proj=longlat +datum=NAD27"))
unnSpP+ lps <- coordinates(nc1)
unnSpP+ ID <- cut(lps[,1], quantile(lps[,1]), include.lowest=TRUE)
unnSpP+ reg4 <- unionSpatialPolygons(nc1, ID)
unnSpP+ row.names(reg4)
unnSpP+ }
Error in rgeos::gUnaryUnion(spgeom = SpP, id = IDs) :
Invalid geometry, may only be applied to polygons
Calls: example ... eval -> eval -> unionSpatialPolygons -> <Anonymous>
Execution halted
Is this not possible?
Thank you,
Joseph Stachelek
We value your opinion. Please take a few minutes to shar...{{dropped:8}}