[R-sig-Geo] Topo to raster in R

Jane Yang jane.juen.yang at gmail.com
Mon Feb 9 06:20:20 CET 2015


Hi all,

Happy Monday! Hoping the collective genius of this listserv can help me. I
have vector contours data (source:
http://192.156.137.110/gis/search.asp?id=318) that I would like to convert
to a surface raster. Two questions:

   1. What are peoples' opinions about the use of spgrass6's r.surf.contour
   functionality vs raster's rasterize function? My basic understanding is
   that GRASS has a more robust algorithm for interpolation, but please do
   correct me if I'm mistaken.

   2. I have been pursuing the r.surf.contour option because initial trials
   with rasterize hasn't converted the majority of the data in the vector
   contour file. However, when I try to load the vector file into a temporary
   GRASS environment, I hit the following error in red, that results in no
   data being transferred over to the raster.

initGRASS("/Applications/GRASS-6.4.app/Contents/MacOS", home=tempdir(),
    override = T)
system("g.region -d")
execGRASS("v.in.ogr", dsn = "path/to/file,
    layer = "kenya_rainfall_distribution", output = "rf_raw2",
    snap = 1e-14)
Warning message:
In execGRASS("v.in.ogr", dsn = paste(dd, "rainfall", "ilri", sep = "/"),  :
  The command:
v.in.ogr dsn=/VOLUMES/AUSTEN/OAF/KE-exp-extras/data/rainfall/ilri
layer=kenya_rainfall_distribution output=rf_raw2 snap=1e-14
produced at least one warning during execution:
ERROR 4: .shx file is unreadable, or corrupt.
ERROR 4: Failed to open file
/VOLUMES/AUSTEN/OAF/KE-exp-extras/data/rainfall/ilri/._kenya_rainfall_distribution.shp.
It may be corrupt or read-only file accessed in update mode.

execGRASS("v.to.rast", input = "rf_raw2", output = "rf_rast", column =
"COLOR",
    labelcolumn = "TYPE")
rf.raster <- execGRASS("r.surf.contour", input = "rf_rast",
    output = "rfraster")

rf.raster
[1] 0
attr(,"resOut")
character(0)
attr(,"resErr")
[1] "   0%\b\b\b\b\b 100%\b\b\b\b\b"


However, I have no problem plotting the map in base plot. Any suggestions
on how to work around this would be much appreciated.

Thank you,
Jane

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list