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

Reply via email to