[R-sig-Geo] Overwrite flag in writeRAST6 is not working...

Jaime R. Garcia Marquez jaime.garcia at uni-bonn.de
Fri Oct 23 11:03:01 CEST 2009


Dear list,

I am running R within a GRASS session. I am trying to convert a  
SpatialGridDataFrame to a raster GRASS format using the writeRAST6  
function. Because the script is inside a for loop I am using the overwrite  
flag to create always a temporal Grass raster file, but it does not work.   
Here is the code:


> class(f)
[1] "SpatialGridDataFrame"
attr(,"package")
[1] "sp"

I would like to create a Grass raster file "temp" which is already there  
 from the first run of the loop

> system("g.list rast")
----------------------------------------------
raster files available in mapset jaime:
glc200_all glc_mode   r_grid     rich_amp   rich_bat   rich_svm   rsr_amp
rsr_bat    rsr_veg    soil_all   soil_mode  temp       wwf_ecos   wwf_mode


----------------------------------------------

> writeRAST6(x=f, vname="temp", zcol=colum[i],flags="overwrite")
Error: option <output>: <temp> exists.
Warning message:
In is.na(pt[, "keydesc_count"]) :
   is.na() applied to non-(list or vector) of type 'NULL'


> writeRAST6(x=f, vname="temp", zcol=colum[i],flags="o")
Error: option <output>: <temp> exists.
Warning message:
In is.na(pt[, "keydesc_count"]) :
   is.na() applied to non-(list or vector) of type 'NULL'


> writeRAST6(x=f, vname="temp", zcol=colum[i], overwrite=TRUE)
Error: option <output>: <temp> exists.
Warning message:
In is.na(pt[, "keydesc_count"]) :
   is.na() applied to non-(list or vector) of type 'NULL'

What I can do is to write at the beginning of the for loop a line to  
delete the file "temp" (system(g.remove rast=temp)) but the overwrite  
possibility is more elegant....

I'd appreciate any help.

Jaime

I am using GRASS 6.2.3

> sessionInfo()
R version 2.9.2 (2009-08-24)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
  [1] RColorBrewer_1.0-2 spdep_0.4-36       Matrix_0.999375-30  
lattice_0.17-26
  [5] spam_0.15-4        boot_1.2-40        tripack_1.3-3      ncf_1.1-3
  [9] spgrass6_0.6-8     XML_2.6-0          classInt_0.1-11     
maptools_0.7-25
[13] foreign_0.8-38     e1071_1.5-19       class_7.2-48       rgdal_0.6-17
[17] sp_0.9-43

loaded via a namespace (and not attached):
[1] grid_2.9.2  tools_2.9.2



More information about the R-sig-Geo mailing list