[R-sig-Geo] RSAGA Vectorizing Grid Classes creates unclosed rings
Roger Bivand
Roger.Bivand at nhh.no
Tue May 11 19:21:51 CEST 2010
On Tue, 11 May 2010, manuel.schneider at art.admin.ch wrote:
> Dear list
>
> I am trying to use SAGA function Vectorizing grid classes from R but
> this creates an unclosed ring in the resulting shapefile. All steps work
> in SAGA GUI. Maybe somebody can reproduce the error and help on it.
> Otherwise, is there a direct way (in the sp framework) to convert grid
> classes into polygons?
>
>> d <- SpatialGridDataFrame(GridTopology(c(0,0), c(1,1), c(5,6)),
> data=data.frame(x=sample(rep(c(NA,1,2),10),30)))
>> write.asciigrid(d, "test.asc" , na.value=-9999)
>> rsaga.esri.to.sgrd(in.grids="test.asc", out.sgrd="classes.sgrd")
>
> SAGA CMD 2.0.3
> library path: C:/ManuProgs/R/R-2.10.1/library/RSAGA/saga_vc/modules
> library name: io_grid
> module name : Import ESRI Arc/Info Grid
> author : (c) 2007 by O.Conrad
> Parameters
> Grid: [not set]
> File: test.asc
> ready
> Save grid: classes.sgrd...
> ready
>
>> rsaga.geoprocessor(lib="shapes_grid", module=6,
> param=list(GRID="classes.sgrd", SHAPES="classes.shp", CLASS_ALL=1))
>
> SAGA CMD 2.0.3
> library path: C:/ManuProgs/R/R-2.10.1/library/RSAGA/saga_vc/modules
> library name: shapes_grid
> module name : Vectorising Grid Classes
> author : (c) 2008 by O.Conrad
> Load grid: classes.sgrd...
> ready
> Parameters
> Grid system: 1; 5x 6y; 0x 0y
> Grid: classes.sgrd
> Shapes: Shapes
> Class Selection: all classes
> Class Identifier: 1.000000
> Vectorised class as...: each island as separated polygon
>
> vectorising class 1: 1.000000
> vectorising class 2: 2.000000
> Save shapes: classes.shp...
> Save shapes: classes.shp
> ready
> Save table: classes.dbf...
> ready
>
>> classes <- readOGR("classes.shp","classes")
> OGR data source with driver: ESRI Shapefile
> Source: "classes.shp", layer: "classes"
> with 8 features and 3 fields
> Feature type: wkbPolygon with 2 dimensions
> Error in is.vector(X) : ring not closed
http://shapelib.maptools.org/dl/shapefile.pdf
does specify that a polygon in a shapefile must be closed. You may be able
to use readShapePoly(..., force_ring=TRUE) in maptools to work around the
problem.
Roger
>
> Thanks in advance
> Manuel
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list