Skip to content

RSAGA Vectorizing Grid Classes creates unclosed rings

4 messages · Roger Bivand, Manuel Schneider, Johan Van de Wauw

#
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?
data=data.frame(x=sample(rep(c(NA,1,2),10),30)))
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
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
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

Thanks in advance
Manuel
#
On Tue, 11 May 2010, manuel.schneider at art.admin.ch wrote:

            
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

  
    
#
Roger Bivand <Roger.Bivand <at> nhh.no> writes:
...
As always, your suggestion does the trick. Thanks a lot.
However, still puzzled why it occurs.
15 days later
#
This is a known error in SAGA.
It will be fixed in the next version
http://saga-gis.cvs.sourceforge.net/viewvc/saga-gis/saga_2/src/modules/shapes/shapes_grid/Grid_Classes_To_Shapes.cpp?view=log

On Tue, May 11, 2010 at 8:02 PM, manuel.schneider
<manuel.schneider at art.admin.ch> wrote: