<div>Dear List,</div>
<div>&nbsp;</div>
<div>I am having some problems analysing some ecoligical models in grass using the spgrass package through R.</div>
<div>&nbsp;</div>
<div>I have 130 plot locations where i have observed presence/absence &nbsp;of a species. </div>
<div>I have followed a similar framework&nbsp;to the BUGSITE modelling example&nbsp;from Markus&#39;s 2003 grass gis handouts (Grass 5)</div>
<div>I have no problems&nbsp;constructing the model based on the 130 plots and the environmental layers from grass.</div>
<div>&nbsp;</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>&nbsp;</div>
<div>However i assume I must convert the spatial grid objects into dataframes to apply the predicted model function.</div>
<div>So&nbsp;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>&nbsp;</div>
<div>I then apply the model predict to the new data frame.</div>
<div>&nbsp;</div>
<div>I am unsure how to then move the &#39;outmap&#39; back across to grass. </div>
<div>How can i convert the df to a spatial grid object.</div>
<div>&nbsp;</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>&nbsp;</div>
<div>Any help would be greatly appreciated.</div>
<div>&nbsp;</div>
<div>Andy</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>#pull through environmental layers </div>
<div>#FAST</div>
<div>anmax &lt;- readRAST6(&quot;anmax&quot;, ignore.stderr=TRUE)<br>anmin &lt;- readRAST6(&quot;anmin&quot;, ignore.stderr=TRUE)<br>aspect &lt;- readRAST6(&quot;aspect&quot;, ignore.stderr=TRUE)<br>dem10_lidar &lt;- readRAST6(&quot;dem10_lidar&quot;, 
ignore.stderr=TRUE)</div>
<div>&nbsp;</div>
<div>#coerce to dataframe</div>
<div>#SLOW</div>
<div>mypred_anmaxDF&lt;-as.data.frame(anmax)<br>mypred_anminDF&lt;-as.data.frame(anmin)<br>mypred_aspectDF&lt;-as.data.frame(aspect)<br>mypred_dem10_lidarDF&lt;-as.data.frame(dem10_lidar)</div>
<div>&nbsp;</div>
<div>#merge into single dataframe</div>
<div>#VERY SLOW<br>merge_tmp&lt;-merge(mypred_anmaxDF,mypred_anminDF)<br>rm(mypred_anmaxDF,mypred_anminDF)<br>merge_tmp1&lt;-merge(merge_tmp,mypred_aspectDF)<br>rm(merge_tmp,mypred_aspectDF)<br>mypredDF&lt;-merge(merge_tmp1,mypred_dem10_lidarDF)
</div>
<div>&nbsp;</div>
<div>#apply model</div>
<div>outmap&nbsp;&nbsp; &lt;- predict(tree,newdata=mypredDF, type=&quot;class&quot;)</div>
<div>&nbsp;</div>