<div>Dear List,</div>
<div> </div>
<div>I am having some problems analysing some ecoligical models in grass using the spgrass package through R.</div>
<div> </div>
<div>I have 130 plot locations where i have observed presence/absence of a species. </div>
<div>I have followed a similar framework to the BUGSITE modelling example from Markus's 2003 grass gis handouts (Grass 5)</div>
<div>I have no problems constructing the model based on the 130 plots and the environmental layers from grass.</div>
<div> </div>
<div>However, I am having problems bringing all the maps through into R so I can make a prediction map. </div>
<div>The region isnt too large 1600 by 800 cells at 10m resolution</div>
<div>I can bring all the environmental layers through to R using readRAST6() which doesnt take too much time at all.</div>
<div> </div>
<div>However i assume I must convert the spatial grid objects into dataframes to apply the predicted model function.</div>
<div>So I then coerce them into dataframes using as.dataframe (this takes ages)</div>
<div>I then merge all the dataframes into a single dataframe. (this takes ages)</div>
<div> </div>
<div>I then apply the model predict to the new data frame.</div>
<div> </div>
<div>I am unsure how to then move the 'outmap' back across to grass. </div>
<div>How can i convert the df to a spatial grid object.</div>
<div> </div>
<div>Im thinking i must be doing something wrong. As it quite quick to pull through the layers . But seems to take quite a lot of processing to get the layers into a datframe appropppriate for applying the predictions.</div>
<div> </div>
<div>Any help would be greatly appreciated.</div>
<div> </div>
<div>Andy</div>
<div> </div>
<div> </div>
<div>#pull through environmental layers </div>
<div>#FAST</div>
<div>anmax <- readRAST6("anmax", ignore.stderr=TRUE)<br>anmin <- readRAST6("anmin", ignore.stderr=TRUE)<br>aspect <- readRAST6("aspect", ignore.stderr=TRUE)<br>dem10_lidar <- readRAST6("dem10_lidar",
ignore.stderr=TRUE)</div>
<div> </div>
<div>#coerce to dataframe</div>
<div>#SLOW</div>
<div>mypred_anmaxDF<-as.data.frame(anmax)<br>mypred_anminDF<-as.data.frame(anmin)<br>mypred_aspectDF<-as.data.frame(aspect)<br>mypred_dem10_lidarDF<-as.data.frame(dem10_lidar)</div>
<div> </div>
<div>#merge into single dataframe</div>
<div>#VERY SLOW<br>merge_tmp<-merge(mypred_anmaxDF,mypred_anminDF)<br>rm(mypred_anmaxDF,mypred_anminDF)<br>merge_tmp1<-merge(merge_tmp,mypred_aspectDF)<br>rm(merge_tmp,mypred_aspectDF)<br>mypredDF<-merge(merge_tmp1,mypred_dem10_lidarDF)
</div>
<div> </div>
<div>#apply model</div>
<div>outmap <- predict(tree,newdata=mypredDF, type="class")</div>
<div> </div>