[R-sig-Geo] creating a raster using import.asc() nd raster()

Juliane Struve juliane_struve at yahoo.co.uk
Fri Jul 8 10:58:56 CEST 2011

Dear list,
I am converting an .asc object into a raster object in order to use functions from the raster package. I then use the converted file to populate an array called FishModel for the purpose of modeling. In the process the columns and rows seem to be confused a some point so that the image of FishModel has the x and y axis reversed. Would someone be able to tell to suggest where this error may arise or shed light on how the ncols and nrows information in the original file is processed by the functions that I am using? 
Thank you very much in advance,
The file bathymetry.asc that I am reading in has the following information: 
ncols         864
nrows         603
xllcorner     299380.196348
yllcorner     2995287.191448
cellsize      100
NODATA_value  -9999
My code:
[1] 864 603
[1] 603 864   1
nrows <- dim(bathymetry)[1]
ncols <- dim(bathymetry)[2]
FishModel <- array(dim=c(nrows,ncols,2))
FishModel[,,1] <- as.matrix(bathymetry)
#in the resulting image x and y axes seem to be reversed

More information about the R-sig-Geo mailing list