Skip to content
Prev 25415 / 29559 Next

Subset a SpLineDF

Dear all,

I'm facing a problem I can't solve even if the solution should not be so
hard to find.

I want to delete the duplicates in a spatial  line dataframe .Those
duplicates have been created by shapesfiles merging on QGis (boundary
rivers are duplicated by the merging of neighbouring departments layers)

So here's the code I wrote :


TRONCON_TOPO_DSAV_coord <-readOGR(dsn = "Sorties/Tron?on
BDTOPO/TRONCON_TOPO_DSAV/Avec coordonn?es", layer =
"TRONCON_TOPO_DSAV_coord")
TRONCON_TOPO_DSAV_coord at data
$doublon<-duplicated(TRONCON_TOPO_DSAV_coord at data$ID)### Create a fied for
duplicate identification
TRONCON_TOPO_DSAV_coord at data<-subset(TRONCON_TOPO_DSAV_coord at data
,TRONCON_TOPO_DSAV_coord at data$doublon=="FALSE")### Subset to delete the
duplicate
TRONCON_TOPO_DSAV_coord at data ### Checking results

writeOGR(TRONCON_TOPO_DSAV_coord,dsn =
path,layer="TRONCON_TOPO_DSAV_coord_unique_test",driver ="ESRI Shapefile")


When I want to export my OGR file,  I get this error message :"Error in
writeOGR(TRONCON_TOPO_DSAV_coord, dsn = path, layer =
"TRONCON_TOPO_DSAV_coord_unique_test",  :
  number of objects mismatch


It seems that I have not the same number of objects in the different
shapefile slots.  How to update these objets after my subset ?


Cheers !

"