Dear Prof. Bivand Tank for help
I tried this cose library(rgdal) canopy_height <- readOGR(".", "theme1") canopy_height$ZDem.sgrd <- canopy_height$Z - canopy_height$Dem.sgrd writeOGR(canopy_height, ".", "canopy_height", driver="ESRI Shapefile") because maptool go out of memory, with rgdal the third column appears empty (value: 0.0000) I attached a small file of my data set. Thanks again for your help and time Ale -----Messaggio originale----- Da: Roger Bivand [mailto:roger.biv...@nhh.no] Inviato: martedì 24 febbraio 2009 10.51 A: Alessandro Cc: r-sig-geo@stat.math.ethz.ch Oggetto: Re: [R-sig-Geo] substract two columns in a shapefile (but SAGA+R has an bug error) On Tue, 24 Feb 2009, Alessandro wrote: > Dear Researcher, > > > > I have a shapefile with two columns "a" and "b" and I wish to subtract a-b > to obtain a new column of difference. I tried in SAGA + R with the module > "Table calculator for shapes". This worked without an error, but it didn't > save the results either. I suspect that this is a bug in the SAGA module. > > > > Is there an another code or packages (without GRASS+R) to do operation with > shapefile? Why not do it the simple way? Either: library(maptools) my_SPDF <- readShapeSpatial("myfile.shp") my_SPDF$ab <- my_SPDF$a - my_SPDF$b writeSpatialShape(my_SPDF, "mynewfile") or: library(rgdal) my_SPDF <- readOGR(".", "myfile") my_SPDF$ab <- my_SPDF$a - my_SPDF$b writeOGR(my_SPDF, ".", "mynewfile", driver="ESRI Shapefile") Insert a summary(my_SPDF) to check that a and b are what you think, and that ab has been created. It won't work if a and/or b are strings. Roger > > > > Thanks > > > > Ale > > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@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.biv...@nhh.no
theme1.shp
Description: Binary data
theme1.shx
Description: Binary data
theme1.dbf
Description: Binary data
theme1.sbn
Description: Binary data
theme1.sbx
Description: Binary data
_______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo