[R-sig-Geo] Subset a SpLineDF

Tristan Bourgeois tristan.bourgeois at gmail.com
Wed Feb 22 11:49:56 CET 2017


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 !

"
-- 
Tristan Bourgeois
Hydromorphologist
Seine Normandie Water Agency
Rouen, France

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list