[R-sig-Geo] unionSpatialPolygons from the command-line
Stachelek, Joseph
jstachel at sfwmd.gov
Thu Apr 7 19:24:05 CEST 2016
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)`
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}}
More information about the R-sig-Geo
mailing list