Hello everyone! I'm a newbie in using the RGDAL and sp packages in R and as written in the object I have a problem with a SPDF and unique():
I would have liked to write a simple script to delete in a couple of clicks the duplicated nodes that sometimes pop-up during the digitizing process in QGIS (I know that this can be done by hand, but when you have lots of features using a script in R would save some time). I tried to use unique() in the "coords" slot, but it simply doesn't work and I can't figure out why. here's a copy of the script that I wrote: > library(rgdal) > p4s<-"+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=1500000 +y_0=0 +ellps=intl +units=m +no_defs" > layer<-c("Kataja") > dsn<-c("C:/Users/vagabond/Desktop/copy_for_r") > spatial<-readOGR(dsn=dsn,layer=layer,p4s=p4s) > len<-length(spatial) > for (i in 1:len){ + temp<-length(spatial@polygons[[i]]@Polygons[[1]]@coords[,1])-1 + spatial@polygons[[i]]@Polygons[[1]]@coords<-unique(spatial@polygons [[i]]@Polygons[[1]]@coords[2:temp,]) + } Thank you very much for the help! Nicola [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.