[R-sig-Geo] how to extract the attribute table of shape files using R

Marcio Pupin Mello mello at ieee.org
Mon Oct 8 12:44:01 CEST 2012


Hi Elaine and Daniela,
    perhaps it is too late to help you, but I decided to reply aiming to 
help another R users with the same problem.

    You can

#read the shapefile - for shape files, dsn is the folder path an layer 
is the shapefile name (without .shp)
shape<-readOGR(dsn="/folder.where.you.file.is/",layer="name.of.your.shapefile")

    then you can access the attribute table by

shape at data

    so you can export it using

write.table(shape at data,"file.name.you.want.to.export.CVS",quote=F,row.names=F,sep=";")


    Good luck!

Marcio
www.dsr.inpe.br/~mello




On 5/3/11 11:04 AM, Daniela Ballari wrote:
> Hi Elaine,
>
> Once you have your data in R, you can use write.table (check documentation
> with ?write.table)
>
> write.table(dataframe, file = "dataframe.csv")
>
> If you don't have your data in R yet, you can see this document:
> http://cran.r-project.org/web/packages/spatstat/vignettes/shapefiles.pdf
>
> Daniela
>
>
> On Tue, May 3, 2011 at 10:30 AM, elaine kuo <elaine.kuo.tw at gmail.com> wrote:
>
>> Dear List,
>>
>> I have a polygon file describing locations of my study region.
>> Now I want to have the attribute table exported as cvs using R.
>> Please kindly advise which package and references are proper for this work.
>>
>> Thank you.
>>
>> Elaine
>>
>>         [[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
>>
>
>
>



More information about the R-sig-Geo mailing list