[R-sig-Geo] lapply and SpatialGridDataFrame

MacQueen, Don macqueen1 at llnl.gov
Mon Jan 28 19:34:56 CET 2013


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" <iruckaE at mail2world.com> 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 
>
>
><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
>R-sig-Geo at r-project.org
>https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list