<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Besedilo oblačka Znak";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.E-potniSlog17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.BesedilooblakaZnak
{mso-style-name:"Besedilo oblačka Znak";
mso-style-priority:99;
mso-style-link:"Besedilo oblačka";
font-family:"Tahoma","sans-serif";
mso-fareast-language:SL;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=SL link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi all, <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>ok i managed to create a prediction with predict() (with gstat object). <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>However, what i get now is a set of predictions and covariances grids for each class. Which is great of course, but what i would really like is to create a map of these classes.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I suppose the maximum value of the prediction on the cell would do, but i can not find a way to make these work. I would need to create a code that would check which value of these predictions (clasess) is the greatest for each cell and set this cell to have a name of the predicted class. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Attached is simplified output of the prediction, where ena.pred, dva.pred, tri.pred……..devet.pred columns represent the prediction (probability) and columns X and Y represent coordinates. So what i would like to do is to generate a code that would check which value is the greates in each X and Y coordinates and assign the name of that column (prediction)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I hope I explained it ok, if not i'll try more…<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks for the hlep, <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>m<o:p></o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> romunov@gmail.com [mailto:romunov@gmail.com] <b>On Behalf Of </b>Roman Luštrik<br><b>Sent:</b> Monday, July 18, 2011 11:21 AM<br><b>To:</b> Matevž Pavlič<br><b>Subject:</b> Re: [R-sig-Geo] predict() LDL error<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Oj,<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>pred časom smo ustanovili lokalno skupino za R, poimenovana Rkoholiki. Navadno se sestajamo v Ljubljani (oddelek za biologijo). Sicer je čez poletje bolj počasno, je pa v času ne-dopustov kar živahno s srečanji. V kolikor bi te zanimalo, se nam lahko pridružiš na <a href="http://groups.google.com/group/rkoholiki">http://groups.google.com/group/rkoholiki</a> kamor obešamo informacije o druženjih in podobno.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>lp,<o:p></o:p></p></div><div><p class=MsoNormal>Roman<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Mon, Jul 18, 2011 at 11:05 AM, Matevž Pavlič <<a href="mailto:matevz.pavlic@gi-zrmk.si">matevz.pavlic@gi-zrmk.si</a>> wrote:<o:p></o:p></p><p class=MsoNormal>Hi,<br><br><br><br>thanks for the help. I renamed it to letters and it works perfectly now.<br><br><br><br>Thanks again for your time, m<o:p></o:p></p><div><p class=MsoNormal><br><br><br>From: caspar hallmann [mailto:<a href="mailto:caspar.hallmann@gmail.com">caspar.hallmann@gmail.com</a>]<o:p></o:p></p></div><p class=MsoNormal>Sent: Monday, July 18, 2011 9:44 AM<br>To: Matevž Pavlič<br>Cc: <a href="mailto:r-sig-geo@r-project.org">r-sig-geo@r-project.org</a><o:p></o:p></p><div><div><p class=MsoNormal style='margin-bottom:12.0pt'>Subject: Re: [R-sig-Geo] predict() LDL error<br><br><br><br>ah...<br><br>I think it has to do with the names. Try renaming your columns so that they dont start with a number but rather a character.<br><br><br><br>names(z)<-paste(letters[1:ncol(z)],names=z,sep="_")<br><br>print(spplot(z, zcol=grep("0.pred",z)), col.regions=terrain.colors(64), contour=T, pretty=T, cuts=8, key.space="right")<br><br>hope it helps<br><br><br><br>Caspar<br><br><br><br>On Mon, Jul 18, 2011 at 9:27 AM, Matevž Pavlič <<a href="mailto:matevz.pavlic@gi-zrmk.si">matevz.pavlic@gi-zrmk.si</a>> wrote:<br><br>Hi Caspar,<br><br><br><br>still get the same error. The str(z) shows this info :<br><br><br><br>> str(z)<br><br>Formal class 'SpatialPixelsDataFrame' [package "sp"] with 7 slots<br><br> ..@ data :'data.frame': 8736 obs. of 9 variables:<br><br> .. ..$ 0.pred : num [1:8736] 0.174 0.174 0.174 0.174 0.176 ...<br><br> .. ..$ 0.var : num [1:8736] 0.236 0.236 0.236 0.236 0.236 ...<br><br> .. ..$ 1.pred : num [1:8736] 0.134 0.134 0.134 0.134 0.117 ...<br><br> .. ..$ 1.var : num [1:8736] 0.136 0.136 0.136 0.136 0.136 ...<br><br> .. ..$ 2.pred : num [1:8736] 0.233 0.233 0.233 0.233 0.234 ...<br><br> .. ..$ 2.var : num [1:8736] 0.0613 0.0613 0.0613 0.0613 0.0613 ...<br><br> .. ..$ cov.0.1: num [1:8736] -0.0509 -0.0509 -0.0509 -0.0509 -0.0509 ...<br><br> .. ..$ cov.0.2: num [1:8736] -0.0171 -0.0171 -0.0171 -0.0171 -0.0171 ...<br><br> .. ..$ cov.1.2: num [1:8736] -0.0164 -0.0164 -0.0164 -0.0164 -0.0164 ... > str(z)<br><br>...<br><br><br><br>But when i use :<br><br><br>> print(spplot(z, zcol=which(names(z)=="0.pred")), col.regions=terrain.colors(64), contour=T, pretty=T, cuts=8, key.space="right")<br><br><br><br><br>i get the same error :<br><br><br>Error in parse(text = x) : <text>:1:3: unexpected symbol<br><br>1: 0.pred<br><br> ^<br><br><br><br>thanks for help,m<br><br><br><br>From: caspar hallmann [mailto:<a href="mailto:caspar.hallmann@gmail.com">caspar.hallmann@gmail.com</a>]<br>Sent: Monday, July 18, 2011 8:58 AM<br>To: Matev¾ Pavliè<br><br>Subject: Re: [R-sig-Geo] predict() LDL error<br><br><br><br><br>Hi Matev¾<br><br><br><br><br>try:<br><br><br><br>print(spplot(z, zcol=which(names(z)=="0.pred")), col.regions=terrain.colors(64), contour=T, pretty=T, cuts=8, key.space="right")<br><br><br><br>Greets<br><br><br><br>Caspar<br><br><br><br><br><br>2011/7/18 Matev¾ Pavliè <<a href="mailto:matevz.pavlic@gi-zrmk.si">matevz.pavlic@gi-zrmk.si</a>><br><br>...and attachement...<br><br>r, m<br><br><br>-----Original Message-----<br><br>From: <a href="mailto:r-sig-geo-bounces@r-project.org">r-sig-geo-bounces@r-project.org</a> [mailto:<a href="mailto:r-sig-geo-bounces@r-project.org">r-sig-geo-bounces@r-project.org</a>] On Behalf Of Matev¾ Pavliè<br>Sent: Monday, July 18, 2011 8:47 AM<br>To: <a href="mailto:r-sig-geo@r-project.org">r-sig-geo@r-project.org</a><br>Subject: Re: [R-sig-Geo] predict() LDL error<br><br>Hi Edzer, thanks for the help,<br><br>i managed to use the predict() function now. But when I try to plot the predictions using spplot() i get this error :<br><br>"Error in parse(text = x) : <text>:1:3: unexpected symbol 1: 0.pred"<br><br>Where 0.pred is the the prediction to plot.<br><br>Does anyone has any ideas to what this could mean? I've searcehd the forum, but failed to get any answers.<br><br>(attached is the code I use).<br><br>Thanks for your time, m<br><br>-----Original Message-----<br>From: <a href="mailto:r-sig-geo-bounces@r-project.org">r-sig-geo-bounces@r-project.org</a> [mailto:<a href="mailto:r-sig-geo-bounces@r-project.org">r-sig-geo-bounces@r-project.org</a>] On Behalf Of Edzer Pebesma<br>Sent: Friday, July 15, 2011 11:15 AM<br>To: <a href="mailto:r-sig-geo@r-project.org">r-sig-geo@r-project.org</a><br>Subject: Re: [R-sig-Geo] predict() LDL error<br><br>to remove duplicates in DF you need to replace it:<br><br>DF = remove.duplicates(DF, zero=0, remove.second = TRUE)<br>zerodist(DF)<br><br>On 07/15/2011 10:23 AM, Matev¾ Pavliè wrote:<br>> Hi, thanks for your time....<br>><br>> I am sure the problem is in same locations...but i dont know why remove.duplicates() does not remove duplicates...<br>> When i try this :<br>><br>>> coordinates(DF)<-~X+Y<br>>> zerodist(DF)<br>> [,1] [,2]<br>> [1,] 83 84<br>> [2,] 242 243<br>> [3,] 266 267<br>> [4,] 431 432<br>> [5,] 439 440<br>> [6,] 731 732<br>> [7,] 817 818<br>> [8,] 820 821<br>><br>>> remove.duplicates(DF, zero=0, remove.second = TRUE)<br>> ...<br>> 1113 (99447.1, 459012) 7019 290.17 286.57 6<br>> 1114 (99465.2, 458975) 7022 291.97 287.27 0<br>> 1115 (99410, 458997) 7015 291.04 288.74 6<br>> 1116 (99495, 458978) 7016 290.62 288.72 6<br>> 1117 (99438.3, 458992) 7018 291.28 288.38 6<br>> 1118 (99813, 458891) 7021 290.08 285.58 0<br>><br>>> zerodist(DF)<br>> [,1] [,2]<br>> [1,] 83 84<br>> [2,] 242 243<br>> [3,] 266 267<br>> [4,] 431 432<br>> [5,] 439 440<br>> [6,] 731 732<br>> [7,] 817 818<br>> [8,] 820 821<br>><br>> it stays the same...shouln't it remove the duplicates?<br>><br>><br>> thanks, m<br>><br>> -----Original Message-----<br>> From: <a href="mailto:r-sig-geo-bounces@r-project.org">r-sig-geo-bounces@r-project.org</a><br>> [mailto:<a href="mailto:r-sig-geo-bounces@r-project.org">r-sig-geo-bounces@r-project.org</a>] On Behalf Of Edzer Pebesma<br>> Sent: Thursday, July 14, 2011 11:25 PM<br>> To: <a href="mailto:r-sig-geo@r-project.org">r-sig-geo@r-project.org</a><br>> Subject: Re: [R-sig-Geo] predict() LDL error<br>><br>> The error message is an indication that you're predicting (kriging) with a singular covariance matrix. The most frequent reasons for this are duplicate observations [1] or perfect correlation in the coregionalization model [2]. For [1], see ?remove.duplicates, for [2] see argument correct.diagonal in ?fit.lmc.<br>><br><br>> On 07/14/2011 06:18 PM, Matev¾ Pavliè wrote:<br>>> Hi all,<br>>><br>>><br>>><br>>> i am trying to use categorical kriging for prediction of soil classes in an area. I am pretty new to using cat. kriging in R soI probably am making some beginers mistakes. Attached is a reproducable sample with sample data.<br>>><br>>><br>>><br>>> When i try to use predict() i geta n error- I am pretty sure because some points are duplicated....in krige() function i use zerodist() which eliminates the LDL error, but i can't find a way to use it here....<br>>><br>>><br>>><br>>> I got this code (mostly) from the net, so i have some trouble understanding it...<br>>><br>>><br>>><br>>> thanks for any help and info about categorical kriging,<br>>><br>>><br>>><br>>> m<br>>><br>>><br>>><br>>><br>>><br>>><br>>><br>>> _______________________________________________<br>>> R-sig-Geo mailing list<br>>> <a href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a><br>>> <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br>><br>> --<br>> Edzer Pebesma<o:p></o:p></p></div></div><p class=MsoNormal>> Institute for Geoinformatics (ifgi), University of Münster Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251 8333081 <<a href="tel:%2B49%20251%208333081">tel:%2B49%20251%208333081</a>> <<a href="tel:%2B49%20251%208333081">tel:%2B49%20251%208333081</a>> , Fax: +49 251 8339763 <<a href="tel:%2B49%20251%208339763">tel:%2B49%20251%208339763</a>> <<a href="tel:%2B49%20251%208339763">tel:%2B49%20251%208339763</a>> <a href="http://ifgi.uni-muenster.de" target="_blank">http://ifgi.uni-muenster.de</a> <<a href="http://ifgi.uni-muenster.de/" target="_blank">http://ifgi.uni-muenster.de/</a>> <<a href="http://ifgi.uni-muenster.de/" target="_blank">http://ifgi.uni-muenster.de/</a>><o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>> <a href="http://www.52north.org/geostatistics" target="_blank">http://www.52north.org/geostatistics</a> <a href="mailto:e.pebesma@wwu.de">e.pebesma@wwu.de</a><br>><br>> _______________________________________________<br>> R-sig-Geo mailing list<br>> <a href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a><br>> <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br>><br>> _______________________________________________<br>> R-sig-Geo mailing list<br>> <a href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a><br>> <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br><br>--<br>Edzer Pebesma<o:p></o:p></p></div><p class=MsoNormal>Institute for Geoinformatics (ifgi), University of Münster Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251 8333081 <<a href="tel:%2B49%20251%208333081">tel:%2B49%20251%208333081</a>> <<a href="tel:%2B49%20251%208333081">tel:%2B49%20251%208333081</a>> , Fax: +49 251 8339763 <<a href="tel:%2B49%20251%208339763">tel:%2B49%20251%208339763</a>> <<a href="tel:%2B49%20251%208339763">tel:%2B49%20251%208339763</a>> <a href="http://ifgi.uni-muenster.de" target="_blank">http://ifgi.uni-muenster.de</a> <<a href="http://ifgi.uni-muenster.de/" target="_blank">http://ifgi.uni-muenster.de/</a>> <<a href="http://ifgi.uni-muenster.de/" target="_blank">http://ifgi.uni-muenster.de/</a>><o:p></o:p></p><div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br><a href="http://www.52north.org/geostatistics" target="_blank">http://www.52north.org/geostatistics</a> <a href="mailto:e.pebesma@wwu.de">e.pebesma@wwu.de</a><br><br>_______________________________________________<br>R-sig-Geo mailing list<br><a href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a><br><a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br><br>_______________________________________________<br>R-sig-Geo mailing list<br><a href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a><br><a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br><br><br>_______________________________________________<br>R-sig-Geo mailing list<br><a href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a><br><a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br><br><br><br><br><br> [[alternative HTML version deleted]]<br><br><br>_______________________________________________<br>R-sig-Geo mailing list<br><a href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a><br><a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br><br><br><br><br> [[alternative HTML version deleted]]<o:p></o:p></p></div></div><p class=MsoNormal style='margin-bottom:12.0pt'><br>_______________________________________________<br>R-sig-Geo mailing list<br><a href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a><br><a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><o:p></o:p></p></div><p class=MsoNormal><br><br clear=all><br>-- <br>In God we trust, all others bring data.<o:p></o:p></p></div></div></body></html>