[R-sig-Geo] raster writing saga grids.
Chuck Bulmer
cebulmer at telus.net
Thu Jan 9 01:12:11 CET 2014
Hi
I am still having problems writing saga grids from raster package. From a
previous thread ( Nov 19, 2013 Guillaume Drolet writeRaster and raster give
same error after package update) it appeared that the problem was solved by
an update but I am running the newest version of raster and still having
trouble.
I've been working around this problem, but would prefer not to have to spell
out the crs each time I load a raster as all of my grids use the same crs.
Are others still experiencing this, or perhaps have I got other issues in my
system.
Thanks!
Chuck
This read command fails:
a <- raster(paste(dir_data,"\\BC_grids\\one_habc.sdat",sep=""))
Error in if (is.null(projs) | is.na(projs) | nchar(projs) < 3) { :
argument is of length zero
In addition: Warning message:
In is.na(projs) : is.na() applied to non-(list or vector) of type 'NULL'
This one works:
a <- raster(paste(dir_data,"\\BC_grids\\one_habc.sdat",sep=""),
crs="+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000
+y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ")
This write command fails to write a saga grid:
> writeRaster(one_habc_b,filename=paste(dir_name,"\\ED_data\\grids\\one_HABC_b.sdat",sep=""),format="SAGA",overwrite=TRUE)
Error in if (is.null(projs) | is.na(projs) | nchar(projs) < 3) { :
argument is of length zero
In addition: Warning message:
In is.na(projs) : is.na() applied to non-(list or vector) of type 'NULL'
This one works if I save as ascii
writeRaster(one_habc_b,filename=paste(dir_name,"\\ED_data\\grids\\one_HABC_b.asc",sep=""),format="ascii",overwrite=TRUE)
This one works if I use gdal to create the saga grid:
writeGDAL(as(one_habc_b, 'SpatialGridDataFrame'), fname =
paste(dir_name,"\\ED_data\\grids\\one_HABC_b.sdat",sep=""), drivername =
"SAGA")
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] randomForest_4.6-7 maptools_0.8-27 rgeos_0.3-2 rgdal_0.8-13
raster_2.1-66 sp_1.0-14
[7] RSAGA_0.93-6 plyr_1.8 shapefiles_0.7 gstat_1.0-18
foreign_0.8-57
loaded via a namespace (and not attached):
[1] grid_3.0.2 intervals_0.14.0 lattice_0.20-24 spacetime_1.0-9
tools_3.0.2 xts_0.9-7
[7] zoo_1.7-10
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/raster-writing-saga-grids-tp7585506.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list