[R-sig-Geo] import sever txt files with one code in (R+SAGA)

Anne Ghisla a.ghisla at studenti.uninsubria.it
Tue Oct 28 14:56:05 CET 2008


On Mon, 2008-10-27 at 11:53 -0700, Alessandro wrote:
> Hi All,
> 
> I have several txt files for a forest structures analysis and I wish to
> import, get coordinates and convert in shape. I need eventually if this code
> is correct:
> 
> (files name: vegetation_2.txt, vegetation_3.txt, etc.etc.)

Hello Alessandro,

may I suggest to use list.files() {base} function to pick up the files?

the code would look like:

files <- list.files(getwd(), pattern="vegetation")
for (i in files) {
# extract coordinates
coordinates(file=i, =~X+Y)
# write as shapefile
writeOGR(obj=i, <other options>, driver="ESRI Shapefile"))
}

hope this helps

Anne Ghisla
Insubria University, Varese (IT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20081028/5cbacc67/attachment.bin>


More information about the R-sig-Geo mailing list