Hello, Could someone please tell if there is a way to append header info to the top of an exported dataframe (exported with write.table). I want to append the following, which are the defininitions for an asciigrid: ncols 532 nrows 999 xllcorner 510465 yllcorner 4766375 cellsize 30 NODATA_value -9999 Thanks very much, femke [[alternative HTML version deleted]]
I suppose one way to do it is to write the header info to the file first (e.g., through connections, or sink(), etc.), then do write.table(..., append=TRUE). HTH, Andy> From: femke > > Hello, > > Could someone please tell if there is a way to append header > info to the top of an exported dataframe (exported with > write.table). I want to append the following, which are the > defininitions for an asciigrid: > > ncols 532 > nrows 999 > xllcorner 510465 > yllcorner 4766375 > cellsize 30 > NODATA_value -9999 > > > Thanks very much, > > femke > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments,...{{dropped}}
You know...I almost added this to your original post because I thought you might want to read something back into ArcInfro when you were done! Look at ?files The easiest thing to do in R is to keep your header as a text file in the working directory and then append it to your output file using 'file.append' write.table(your output file) file.copy("header.txt", "final.output.txt") file.append("final.output.txt", "output.dat") Using 'paste' for the file names makes this easy and flexible. HTH, Andy> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of femke > Sent: Thursday, February 26, 2004 2:16 PM > To: r-help at stat.math.ethz.ch > Subject: [R] adding header info to write.table > > > Hello, > > Could someone please tell if there is a way to append header > info to the top of an exported dataframe (exported with > write.table). I want to append the following, which are the > defininitions for an asciigrid: > > ncols 532 > nrows 999 > xllcorner 510465 > yllcorner 4766375 > cellsize 30 > NODATA_value -9999 > > > Thanks very much, > > femke > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo> /r-help > PLEASE > do read the posting guide! > http://www.R-project.org/posting-guide.html > >
On Thu, 26 Feb 2004, femke wrote:> Hello, > > Could someone please tell if there is a way to append header info to the > top of an exported dataframe (exported with write.table). I want to > append the following, which are the defininitions for an asciigrid: > > ncols 532 > nrows 999 > xllcorner 510465 > yllcorner 4766375 > cellsize 30 > NODATA_value -9999 >zz <- file("myraster", "w") cat("ncols 532\nnrows 999\n", file=zz) cat("xllcorner 510465\nyllcorner 4766375\n", file=zz) cat("cellsize 30\nNODATA_value -9999\n", file=zz) write.table(data, file=zz, append=TRUE, col.names=FALSE, row.names=FALSE) close(zz) using connections (see help(connections)) and the append= argument in write.table. Is everybody writing ArcGIS ASCII rasters recently?> > Thanks very much, > > femke > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: Roger.Bivand at nhh.no
On Thu, 26-Feb-2004 at 04:15PM -0500, femke wrote: |> Hello, |> |> Could someone please tell if there is a way to append header info |> to the top of an exported dataframe (exported with write.table). I |> want to append the following, which are the defininitions for an |> asciigrid: |> ncols 532 |> nrows 999 |> xllcorner 510465 |> yllcorner 4766375 |> cellsize 30 |> NODATA_value -9999 ?write then use append = TRUE when using write.table HTH -- Patrick Connolly HortResearch Mt Albert Auckland New Zealand Ph: +64-9 815 4200 x 7188 ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~ I have the world`s largest collection of seashells. I keep it on all the beaches of the world ... Perhaps you`ve seen it. ---Steven Wright ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
A minor variant is to use "cat" for the initial headers: DF <- data.frame(a=1:2, b=c("a","B")) cat("header1\nheader2\n", file="filename.csv") cat("header3\n", file="filename.csv", append=TRUE) write.table(DF, file="filename.csv", append=TRUE) In S-Plus 6.2 and R 1.8.2, this produces the following: header1 header2 header3 "a" "b" "1" 1 "a" "2" 2 "B" hope this helps. spencer graves Liaw, Andy wrote:>I suppose one way to do it is to write the header info to the file first >(e.g., through connections, or sink(), etc.), then do write.table(..., >append=TRUE). > >HTH, >Andy > > > >>From: femke >> >>Hello, >> >>Could someone please tell if there is a way to append header >>info to the top of an exported dataframe (exported with >>write.table). I want to append the following, which are the >>defininitions for an asciigrid: >> >>ncols 532 >>nrows 999 >>xllcorner 510465 >>yllcorner 4766375 >>cellsize 30 >>NODATA_value -9999 >> >> >>Thanks very much, >> >>femke >> [[alternative HTML version deleted]] >> >>______________________________________________ >>R-help at stat.math.ethz.ch mailing list >>https://www.stat.math.ethz.ch/mailman/listinfo/r-help >>PLEASE do read the posting guide! >>http://www.R-project.org/posting-guide.html >> >> >> >> > > >------------------------------------------------------------------------------ >Notice: This e-mail message, together with any attachments,...{{dropped}} > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >
> Is everybody writing ArcGIS ASCII rasters recently?The GIS community is hopelessly tied to ESRI. So many people have invested their careers in learning Arc that switching to GRASS is an institutional nightmare. Most of what I do now is outside of Arc! And certainly outside of their almost useless GUI.