[R-sig-Geo] difficult to subtract two column of my shapefile
Alexander Brenning
brenning at uwaterloo.ca
Tue Feb 24 15:37:23 CET 2009
Hi there,
to throw in two more alternatives, there are functions read.dbf and
write.dbf in packages shapefiles and foreign (see help files for
examples; the functions differ between the two packages despite having
the same name).
Remember that operations on the shapefile attributes only affect the dbf
file of the shape"file" (which is not really a file but a set of files).
So this will work as long as you don't change the number or order of the
rows.
This may also be more efficient if the shapes have complex geometry
(e.g. complex polygons, contour lines...), because the geometry is not
imported by the functions I mentioned.
Cheers
Alex
Alessandro wrote:
> Thanks for all help
>
>
>
> I wish two subtract two column of my shapefile but It look like a impossible
> operation with R:
>
>
>
> 1. In SAGA+R module: "Table calculator for shapes", It runs but doesn't
> save the result (there is bug)
>
> 2. I can't use software "GeoDa" because It works only in Windows xp and
> not in Windows Vista
>
> 3. Library maptools go down for a memory problems
>
> 4. library(rgdal) give an empty column
>
>
>
> is there suggestion? please.
>
>
>
> I attach a small part of my data-set for
>
>
>
> Thanks for Help and suggestion
>
>
>
>
>
> library(maptools)
>
> my_SPDF <- readShapeSpatial("theme1.shp")
>
> my_SPDF$ab <- my_SPDF$a - my_SPDF$b
>
> writeSpatialShape(my_SPDF, "mynewfile")
>
>
>
> or:
>
>
>
> library(rgdal)
>
> my_SPDF <- readOGR(".", "theme1")
>
> my_SPDF$ab <- my_SPDF$a - my_SPDF$b
>
> writeOGR(my_SPDF, ".", "mynewfile", driver="ESRI Shapefile")
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Alexander Brenning
brenning at uwaterloo.ca - T +1-519-888-4567 ext 35783
Department of Geography and Environmental Management
University of Waterloo
200 University Ave. W - Waterloo, ON - Canada N2L 3G1
http://www.fes.uwaterloo.ca/geography/faculty/brenning/
More information about the R-sig-Geo
mailing list