[STATSGRASS] cant read raster created with r.neighbours

Carlos "Guâno" Grohmann carlos.grohmann at gmail.com
Thu Jul 26 13:15:37 EDT 2007


Here is the debug output:

> debug(readBinGrid)
> slopeavg<-readRAST6("dem3arcsec_srtm_reprojected_slope_avg2")
Creating BIL support files ...
Header File = .wld
World File =
/home/guano/grassdata/srtm_krig_utm/death_valley/.tmp/eclipse/dem3arcsec_srtm_reprojected_slope_avg2.wld
Exporting Raster as floating values (bytes=4)
Using the Current Region settings ...
north=4031000.000000
south=4002650.000000
east=494850.000000
west=466500.000000
r=315
c=315
 100%
debugging in: readBinGrid(rtmpfl11, colname = vname[i], proj4string =
p4, integer = to_int)
debug: {
    if (missing(integer))
        stop("integer TRUE/FALSE required")
    if (!file.exists(fname))
        stop(paste("no such file:", fname))
    if (!file.exists(paste(fname, "hdr", sep = ".")))
        stop(paste("no such file:", paste(fname, "hdr", sep = ".")))
    if (!file.exists(paste(fname, "wld", sep = ".")))
        stop(paste("no such file:", paste(fname, "wld", sep = ".")))
    con <- file(paste(fname, "hdr", sep = "."), "r")
    l8 <- readLines(con, n = 8)
    close(con)
    l8 <- read.dcf(textConnection(gsub(" ", ":", l8)))
    lres <- as.list(l8)
    names(lres) <- colnames(l8)
    lres$nrows <- as.integer(lres$nrows)
    lres$ncols <- as.integer(lres$ncols)
    lres$nbands <- as.integer(lres$nbands)
    lres$nbits <- as.integer(lres$nbits)
    lres$skipbytes <- as.integer(lres$skipbytes)
    lres$nodata <- ifelse(integer, as.integer(lres$nodata),
as.numeric(lres$nodata))
    con <- file(paste(fname, "wld", sep = "."), "r")
    l6 <- readLines(con, n = 6)
    close(con)
    lres$ewres <- abs(as.numeric(l6[1]))
    lres$nsres <- abs(as.numeric(l6[4]))
    lres$n_cc <- as.numeric(l6[6])
    lres$w_cc <- as.numeric(l6[5])
    lres$s_cc <- lres$n_cc - lres$nsres * (lres$nrows - 1)
    what <- ifelse(integer, "integer", "double")
    n <- lres$nrows * lres$ncols
    size <- lres$nbits/8
    map <- readBin(fname, what = what, n = n, size = size, signed = TRUE)
    is.na(map) <- map == lres$nodata
    grid = GridTopology(c(lres$w_cc, lres$s_cc), c(lres$ewres,
        lres$nsres), c(lres$ncols, lres$nrows))
    df <- list(var1 = map)
    names(df) <- colname
    if (.sp_lt_0.9()) {
        df1 <- AttributeList(df)
    }
    else {
        df1 <- data.frame(df)
    }
    res <- SpatialGridDataFrame(grid, data = df1, proj4string = proj4string)
    res
}
Browse[1]> list.files(dirname(fname))
 [1] "162.0"
 [2] "162.1"
 [3] "162.2"
 [4] "260.0"
 [5] "260.1"
 [6] "260.2"
 [7] "284.0"
 [8] "284.1"
 [9] "284.2"
[10] "336.0"
[11] "336.1"
[12] "393.0"
[13] "393.1"
[14] "436.0"
[15] "436.1"
[16] "436.2"
[17] "436.3"
[18] "441.0"
[19] "60.0"
[20] "60.1"
[21] "60.2"
[22] "60.3"
[23] "6183.0"
[24] "6183.1"
[25] "6183.1.ppm"
[26] "6183.2"
[27] "6183.2.pgm"
[28] "6183.2.ppm"
[29] "6183.3"
[30] "6183.3.pgm"
[31] "6183.3.ppm"
[32] "653.0"
[33] "653.1"
[34] "653.2"
[35] "653.3"
[36] "653.4"
[37] "653.5"
[38] "661.0"
[39] "661.1"
[40] "661.2"
[41] "6630.0"
[42] "6630.1"
[43] "753.0"
[44] "753.1"
[45] "753.2"
[46] "786.0"
[47] "786.1"
[48] "786.2"
[49] "796.0"
[50] "796.1"
[51] "796.2"
[52] "796.3"
[53] "796.4"
[54] "846.0"
[55] "846.1"
[56] "846.2"
[57] "846.3"
[58] "847.0"
[59] "847.1"
[60] "847.2"
[61] "847.3"
[62] "940.0"
[63] "dem3arcsec_srtm_reprojected_aspect"
[64] "dem3arcsec_srtm_reprojected_slope_avg2"
[65] "dem3arcsec_srtm_reprojected_slope_avg2.wld"
Browse[1]>
debug: if (missing(integer)) stop("integer TRUE/FALSE required")
Browse[1]>
debug: if (!file.exists(fname)) stop(paste("no such file:", fname))
Browse[1]>
debug: if (!file.exists(paste(fname, "hdr", sep = ".")))
stop(paste("no such file:",
    paste(fname, "hdr", sep = ".")))
Browse[1]>
Error in readBinGrid(rtmpfl11, colname = vname[i], proj4string = p4,
integer = to_int) :
        no such file:
/home/guano/grassdata/srtm_krig_utm/death_valley/.tmp/eclipse/dem3arcsec_srtm_reprojected_slope_avg2.hdr
>


and then with a short file name


> elev<-readRAST6("srtm3sec_reprojected")
Creating BIL support files ...
Header File =
/home/guano/grassdata/srtm_krig_utm/death_valley/.tmp/eclipse/srtm3sec_reprojected.hdr
World File =
/home/guano/grassdata/srtm_krig_utm/death_valley/.tmp/eclipse/srtm3sec_reprojected.wld
Exporting Raster as floating values (bytes=4)
Using the Current Region settings ...
north=4031000.000000
south=4002650.000000
east=494850.000000
west=466500.000000
r=315
c=315
 100%
debugging in: readBinGrid(rtmpfl11, colname = vname[i], proj4string =
p4, integer = to_int)
debug: {

<snip>

[60] "847.1"
[61] "847.2"
[62] "847.3"
[63] "940.0"
[64] "dem3arcsec_srtm_reprojected_aspect"
[65] "dem3arcsec_srtm_reprojected_slope_avg2"
[66] "dem3arcsec_srtm_reprojected_slope_avg2.wld"
[67] "srtm3sec_reprojected"
[68] "srtm3sec_reprojected.hdr"
[69] "srtm3sec_reprojected.wld"
Browse[1]>
debug: if (missing(integer)) stop("integer TRUE/FALSE required")


So it appears to me that for some reason the .hdr was not attached to
the file...


Carlos




+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano
  Visiting Researcher at Kingston University London - UK
  Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
Linux User #89721  - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

Can't stop the signal.




More information about the grass-stats mailing list