Irucka Embry <iruckaE <at> mail2world.com> writes:

> 
> Hi all, I have a set of 54 files that I need to convert from ASCII grid
> format to .shp files to .bnd files for BayesX.
> 
> I have the following R code to operate on those files:
> 
> library(maptools)
> library(Grid2Polygons)
> library(BayesX)
> library(BayesXsrc)
> library(R2BayesX)
> 
> readfunct <- function(x)
> {
> u <- readAsciiGrid(x)
> }
> 
> modfilesmore <- paste0("MaxFloodDepth_", 1:54, ".txt")
> modeldepthsmore <- lapply(modfilesmore, readfunct)
> 
> maxdepth.plys <- lapply(modeldepthsmore, Grid2Polygons(modeldepthsmore,
> level = FALSE))
> 
...
> 
> This is the error message that I receive:
> > maxdepth.plys <- lapply(modeldepthsmore,
> Grid2Polygons(modeldepthsmore, level = FALSE))
> Error in Grid2Polygons(modeldepthsmore, level = FALSE) : Grid object not
> of class SpatialGridDataFrame
> 
> Can someone assist me in modifying the R code so that I can convert the
> set of files to .shp files and then to .bnd files for BayesX?

You also posted on R-sig-geo a few hours after posting here - certainly a more
relevant choice of list, but you are rather impatient.

I'm assuming that you have read up on how lapply() works, and realised what is
wrong with your understanding. But just in case, 

> maxdepth.plys <- lapply(modeldepthsmore, Grid2Polygons(modeldepthsmore,
> level = FALSE))

does not pass the list component from modeldepthsmore anywhere, but tries to run
Grid2Polygons on the whole list. Something like (untried):

maxdepth.plys <- lapply(modeldepthsmore, function(x) Grid2Polygons(x, level =
FALSE))

should do that. Please summarise to R-sig-geo.

Roger


> 
> Thank-you.
> 
> Irucka Embry 
>

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to