[R] adding header info to write.table

Roger Bivand Roger.Bivand at nhh.no
Thu Feb 26 22:31:12 CET 2004


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




More information about the R-help mailing list