Hi Don MacQueen, I want to thank you for your response.
I received assistance from the main R help mailing list with this code
suggestion: maxdepth.plys <- lapply(modeldepthsmore, function(x)
Grid2Polygons(x, level = FALSE)). I have not allowed that code
suggestion or your suggestion to complete all 54 polygons because it has
taken too long. Thus I thought about revising the code that you provided
me to save each polygon to a file so that I can know which files have
been completed and which ones have not been yet.
I have tried to update the previous R code to save each output file to a
folder:
library(maptools)
library(Grid2Polygons)
readfunct <- function(x)
{
u <- readAsciiGrid(x)
}
modfilesmore <- paste0("MaxFloodDepth_", 1:54, ".txt")
modeldepthsmore <- lapply(modfilesmore, readfunct)
myfolder <- paste0("/MaxFloodDepthImages/MaxFloodDepthPolygon_", 1:54)
maxdepth.plys <- lapply(modeldepthsmore, Grid2Polygons, level=FALSE,
cat, file = "myfolder", append = TRUE)
Error in FUN(X[[1L]], ...) :
unused argument(s) (file = "myfolder", append = TRUE)
<-----Original Message----->
>From: MacQueen, Don [[email protected]]
>Sent: 1/28/2013 12:34:56 PM
>To: [email protected];[email protected]
>Subject: Re: [R-sig-Geo] lapply and SpatialGridDataFrame
>
>I suspect you're not passing arguments correctly to lapply()
>
>I'd try
> maxdepth.plys <- lapply(modeldepthsmore, Grid2Polygons, level=FALSE)
>
>-Don
>
>
>
>--
>Don MacQueen
>
>Lawrence Livermore National Laboratory
>7000 East Ave., L-627
>Livermore, CA 94550
>925-423-1062
>
>
>
>
>
>On 1/27/13 2:47 AM, "Irucka Embry" <[email protected]> wrote:
>
>>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)
>>
>>readfunct <- function(x)
>>{
>>u <- readAsciiGrid(x)
>>}
>>
>>modfilesmore <- paste0("MaxFloodDepth_", 1:54, ".txt")
>>modeldepthsmore <- lapply(modfilesmore, readfunct)
>>
>>maxdepth.plys <- lapply(modeldepthsmore,
Grid2Polygons(modeldepthsmore,
>>level = FALSE))
>>
>>layers <- paste0("examples/floodlayers_", 1:54)
>>writePolyShape(maxdepth.plys, layers)
>>shpName <- sub(pattern="(.*)\\.dbf", replacement="\\1",
>>x=system.file("examples/Flood/layer_.dbf", package="BayesX"))
>>floodmaps <- shp2bnd(shpname=shpName, regionnames="SP_ID")
>>
>>## draw the map
>>drawmap(map=floodmaps)
>>
>>
>>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?
>>
>>Thank-you.
>>
>>Irucka Embry
>>_______________________________________________
>>R-sig-Geo mailing list
>>[email protected]
>>https://stat.ethz.ch/mailman/listinfo/r-sig-geo
<span id=m2wTl><p><font face="Arial, Helvetica, sans-serif" size="2"
style="font-size:13.5px">_______________________________________________________________<BR>Get
the Free email that has everyone talking at <a href=http://www.mail2world.com
target=new>http://www.mail2world.com</a><br> <font color=#999999>Unlimited
Email Storage – POP3 – Calendar – SMS – Translator –
Much More!</font></font></span>
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo