[R-sig-Geo] adding variable to shapefile

Tom Gottfried tom.gottfried at wzw.tum.de
Mon Mar 21 20:09:54 CET 2011


you can even operate directly on the object you obtained from reading the shapefile. To add a column 
called test just do

s$test <- test

assuming that test has length(test)==nrow(s). In case you want it back in the shapefile use 
writePolyShape.

Tom

Am 21.03.2011 19:56, schrieb Johannes Signer:
> You can access the data slot of a shapefile s by:
>
> d<- s at data
>
> d is data frame, where you can a column and write it back to the shapefile.
>
> s at data<- d
>
> Hope this helps
> Johannes
>
> On Mon, Mar 21, 2011 at 7:29 PM, Advait Godbole<advaitgodbole at gmail.com>wrote:
>
>> Dear R-users,
>>
>> I am reading a shapefile in to R using readShapePoly, do some spatial
>> modeling on it and obtain a new variable which I want to write to the same
>> polygons as a new attribute (variable) preserving the spatial structure. Is
>> there a straightforward way of doing it via a "write-to-shapefile"
>> function?
>>
>> Thanks in advance,
>>
>> --
>> advait godbole
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Technische Universität München
Department für Pflanzenwissenschaften
Lehrstuhl für Grünlandlehre
Alte Akademie 12
85350 Freising / Germany
Phone: ++49 (0)8161 715324
Fax:   ++49 (0)8161 713243
email: tom.gottfried at wzw.tum.de
http://www.wzw.tum.de/gruenland



More information about the R-sig-Geo mailing list