The case for a as.data.frame(signature=RasterStack) method (then you would have three lines (one less than Kamran)
-----Original Message----- From: r-sig-geo-boun...@stat.math.ethz.ch [mailto:r-sig-geo-boun...@stat.math.ethz.ch] On Behalf Of Kamran Safi Sent: Thursday, January 15, 2009 3:28 PM To: Robert Hijmans; Juliane Struve Cc: R-sig-Geo@stat.math.ethz.ch Subject: Re: [R-sig-Geo] Reading an Ascii file Hi all, This should deliver the results Julie is looking for: library(rgdal) library(maptools) grid <- readAsciiGrid("<your file and its path>") table <- data.frame(grid) That was it! Replace s1 and s2 with X and Y. Kamran ------------------------ Kamran Safi Postdoctoral Research Fellow Institute of Zoology Zoological Society of London Regent's Park London NW1 4RY http://www.zoo.cam.ac.uk/ioz/people/safi.htm http://spatialr.googlepages.com http://asapi.wetpaint.com -----Original Message----- From: r-sig-geo-boun...@stat.math.ethz.ch on behalf of Robert Hijmans Sent: Thu 15.01.2009 03:13 To: Juliane Struve Cc: R-sig-Geo@stat.math.ethz.ch Subject: Re: [R-sig-Geo] Reading an Ascii file Dear Julie, This is one way to do that, using the raster package (under development): install.packages("raster", repos="http://R-Forge.R-project.org<http://r-forge.r-project.org/> ") require(raster) r <- rasterFromFile("d:/alt.asc", TRUE) xy <- xyFromCell(r, 1:ncells(r)) xyv <- cbind(xy, values(r)) xyv[1:10,] # To get rid of the NAs xyv <- na.omit(xyv) xyv[1:10,] On Thu, Jan 15, 2009 at 1:01 AM, Juliane Struve <juliane_str...@yahoo.co.uk>wrote: > Dear list, > > I am trying to read ArcGIS raster data sets into R after converting them > into ASCII .txt file. The text file I am trying to read contains > > ncols 250 > nrows 276 > xllcorner 344147.19411119 > yllcorner 3024657.6122834 > cellsize 0.19970250725746 > NODATA_value -9999 > > in the first lines followed by a grid of values that are either -9999 or 1. > > I have used read.table("myfile.txt") which yields this (first 10 lines). > > > V1 V2 > 1 ncols 2.500000e+02 > 2 nrows 2.760000e+02 > 3 xllcorner 3.441472e+05 > 4 yllcorner 3.024658e+06 > 5 cellsize 1.997025e-01 > 6 NODATA_value -9.999000e+03 > 7 -9999 -9.999000e+03 > 8 -9999 -9.999000e+03 > 9 -9999 -9.999000e+03 > 10 -9999 -9.999000e+03 > > I would like to have the data as a table with coordinates for each cell and > the actual value. > > Could somebody advise me which function I should use ? > > Many thanks, > > Juliane > > > > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo Click https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg== to report this email as spam. The Zoological Society of London is incorporated by Royal Charter Principal Office England. Company Number RC000749 Registered address: Regent's Park, London, England NW1 4RY Registered Charity in England and Wales no. 208728 ________________________________________________________________________ _ This e-mail has been sent in confidence to the named\ ad...{{dropped:8}} _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo