Skip to content

adding header info to write.table

5 messages · femke, Roger Bivand, Patrick Connolly +1 more

#
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
#
On Thu, 26 Feb 2004, femke wrote:

            
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?

  
    
#
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
#
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.