[R-sig-Geo] asciigrid R

Roger Bivand Roger.Bivand at nhh.no
Mon Dec 3 22:05:52 CET 2007


On Mon, 3 Dec 2007, Jose Funes wrote:

> ASCIIGRID
>
> I am using read.asciigrid function from R to import 4 grid maps from
> ArcGIS to a single grid in R. However, I am having troubles to make it
> work, when I finish to import the 4 grid to R the final grid appear as
> NULL. Below I did include the code, I will appreciate your help to
> solve this problem.I tried to register to GTAT group but my email is
> returned.
>
> Thanks,
>
> R code:
>
> Four layers were stacked:
> explanatory$silt = read.asciigrid("silt.asc")$band1
> explanatory$silt = explanatory$band1
>
> explanatory$sand = read.asciigrid("sandasc.asc")$band1
> explanatory$sand = explanatory$band1
>
> explanatory$nd = read.asciigrid("nd.asc")$band1
> explanatory$nd = explanatory$band1
>
> explanatory$bnd3 = read.asciigrid("bnd3.asc")$band1
> explanatory$bnd3 = explanatory$band1

Maybe:

library(maptools)
explanatory <- readAsciiGrid("silt.asc")
explanatory <- cbind(explanatory, readAsciiGrid("sandasc.asc"))
explanatory <- cbind(explanatory, readAsciiGrid("nd.asc"))
explanatory <- cbind(explanatory, readAsciiGrid("bnd3.asc"))
names(explanatory) <- c("silt", "sand", "nd", "bnd3")

Please also see ?readAsciiGrid and check the dec= and the na.value= 
arguments - the version you are using in sp is not as often used as the 
one in maptools. You can also use readGDAL() in the rgdal package.

Roger

>
>
> Deleting double band:
> explanatory$band1 = NULL
>
> str(explanatory)
> NULL
>
> Jose Funes
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list