<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=iso-8859-1"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@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;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"Lucida Console";
panose-1:2 11 6 9 4 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
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;}
pre
{mso-style-priority:99;
mso-style-link:"Préformaté HTML Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Texte de bulles Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";
mso-fareast-language:EN-US;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.TextedebullesCar
{mso-style-name:"Texte de bulles Car";
mso-style-priority:99;
mso-style-link:"Texte de bulles";
font-family:"Tahoma","sans-serif";}
span.PrformatHTMLCar
{mso-style-name:"Préformaté HTML Car";
mso-style-priority:99;
mso-style-link:"Préformaté HTML";
font-family:"Courier New";
mso-fareast-language:FR-CA;}
span.gjwpqfqdn4
{mso-style-name:gjwpqfqdn4;}
span.gjwpqfqdb4
{mso-style-name:gjwpqfqdb4;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
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=FR-CA link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hello!<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>I have already searched the Forum’s archives and sp documentation, but the answer is still unclear to this basic question : how can you clip a SpatialGridDataFrame with a SpatialPolygons and return a new clipped SpatialGridDataFrame (not a vector !).<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Here is my data as an example :<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:blue;mso-fareast-language:FR-CA'>> summary(D.tls.SPGDF)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>Object of class SpatialGridDataFrame<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>Coordinates:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'> min max<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>[1,] 828049.000 828191.000<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>[2,] 101770.000 101915.000<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>[3,] 321.632 480.632<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>Is projected: TRUE <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>proj4string :<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>[+init=epsg:27561 +proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>+k_0=0.999877341 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>+towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs]<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>Grid attributes:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'> cellcentre.offset cellsize cells.dim<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>1 828049.500 1 142<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>2 101770.500 1 145<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>3 322.132 1 159<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'>Data attributes:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'> Min. 1st Qu. Median Mean 3rd Qu. Max. NA's <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:black;mso-fareast-language:FR-CA'> 0.000 0.000 0.000 0.000 0.000 0.969 6895.000 <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><pre><span class=gjwpqfqdn4><span lang=EN-US style='font-family:"Lucida Console";color:blue'>> </span></span><span class=gjwpqfqdb4><span lang=EN-US style='font-family:"Lucida Console";color:blue'>summary(g)<o:p></o:p></span></span></pre><pre><span lang=EN-US style='font-family:"Lucida Console";color:black'>Object of class SpatialPolygons<o:p></o:p></span></pre><pre><span style='font-family:"Lucida Console";color:black'>Coordinates:<o:p></o:p></span></pre><pre><span style='font-family:"Lucida Console";color:black'> min max<o:p></o:p></span></pre><pre><span style='font-family:"Lucida Console";color:black'>x 828103.9 828133.9<o:p></o:p></span></pre><pre><span style='font-family:"Lucida Console";color:black'>y 101839.3 101869.3<o:p></o:p></span></pre><pre><span lang=EN-US style='font-family:"Lucida Console";color:black'>Is projected: TRUE <o:p></o:p></span></pre><pre><span lang=EN-US style='font-family:"Lucida Console";color:black'>proj4string :<o:p></o:p></span></pre><pre><span lang=EN-US style='font-family:"Lucida Console";color:black'>[+init=epsg:27561 +proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0<o:p></o:p></span></pre><pre><span lang=EN-US style='font-family:"Lucida Console";color:black'>+k_0=0.999877341 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515<o:p></o:p></span></pre><pre><span lang=EN-US style='font-family:"Lucida Console";color:black'>+towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs]<o:p></o:p></span></pre><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>If I do :<o:p></o:p></span></p><pre><span class=gjwpqfqdn4><span lang=EN-US style='font-family:"Lucida Console";color:blue'>> </span></span><span class=gjwpqfqdb4><span lang=EN-US style='font-family:"Lucida Console";color:blue'>o <- overlay(D.tls.SPGDF, g)</span></span><span lang=EN-US style='font-family:"Lucida Console";color:black'><o:p></o:p></span></pre><p class=MsoNormal><span lang=EN-US>R returns a vector <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Which is the function that returns the initial object i.e. SpatialGridDataFrame ?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Nathalie<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Nathalie MORIN<o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Docto</span><span style='color:#595959;mso-fareast-language:FR-CA'>rante en télédétection forestière <i>(Ph.D student in remote sensing applied to forestry)</i></span><span style='color:#595959;mso-fareast-language:FR-CA'><o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Centre d’application et de recherches en télédétection (CARTEL)<o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Département de Géomatique Appliquée<o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Sherbrooke (QC) CANADA J1K 2R1<o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Tél. : + 1 (819) 821-8000 #62962<o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>e-mail : <a href="mailto:Nathalie.M.Morin@Usherbrooke.ca"><span style='color:#595959'>Nathalie.M.Morin@Usherbrooke.ca</span></a><o:p></o:p></span></p><p class=MsoNormal><a href="http://www.usherbrooke.ca/"><span style='font-size:9.5pt;font-family:"Verdana","sans-serif";color:#7F7F7F;mso-fareast-language:FR-CA;text-decoration:none'><img border=0 width=175 height=40 id="Image_x0020_1" src="cid:image001.gif@01CDDD07.BFE68E80" alt="Université de Sherbrooke"></span></a><span style='mso-fareast-language:FR-CA'><o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>